=# EXPLAIN ANALYZE SELECT * FROM medley LIMIT 30 OFFSET 5000000;
Limit (cost=91666.88..91667.43 rows=30 width=37) (actual time=501.497..501.502 rows=30 loops=1)
-> Seq Scan on medley (cost=0.00..183334.29 rows=10000029 width=37) (actual time=0.006..341.246 rows=5000030 loops=1)
Planning time: 0.053 ms
Execution time: 501.523 ms
=# EXPLAIN ANALYZE SELECT * FROM medley t1 JOIN (SELECT n FROM medley ORDER BY n LIMIT 30 OFFSET 5000000) as t2 ON t2.n = t1.n;
Nested Loop (cost=129844.71..130099.23 rows=30 width=41) (actual time=600.520..600.580 rows=30 loops=1)
-> Limit (cost=129844.28..129845.06 rows=30 width=4) (actual time=600.506..600.507 rows=30 loops=1)
-> Index Only Scan using medley_n_idx on medley (cost=0.43..259688.87 rows=10000029 width=4) (actual time=0.013..446.107 rows=5000030 loops=1)
Heap Fetches: 0
-> Index Scan using medley_n_idx on medley t1 (cost=0.43..8.45 rows=1 width=37) (actual time=0.001..0.001 rows=1 loops=30)
Index Cond: (n = medley.n)
Planning time: 0.222 ms
Execution time: 600.607 ms
Давным давно выбрал Yii2 из эстетических соображений и ни разу об этом не пожалел.
Если найду в нем баг, с работью пришлю им pull request и заработаю ещё +1 в карму ))
psql (PostgreSQL) 9.5.2
=# EXPLAIN ANALYZE SELECT * FROM medley LIMIT 30 OFFSET 5000000;
Limit (cost=91666.88..91667.43 rows=30 width=37) (actual time=501.497..501.502 rows=30 loops=1)
-> Seq Scan on medley (cost=0.00..183334.29 rows=10000029 width=37) (actual time=0.006..341.246 rows=5000030 loops=1)
Planning time: 0.053 ms
Execution time: 501.523 ms
=# EXPLAIN ANALYZE SELECT * FROM medley t1 JOIN (SELECT n FROM medley ORDER BY n LIMIT 30 OFFSET 5000000) as t2 ON t2.n = t1.n;
Nested Loop (cost=129844.71..130099.23 rows=30 width=41) (actual time=600.520..600.580 rows=30 loops=1)
-> Limit (cost=129844.28..129845.06 rows=30 width=4) (actual time=600.506..600.507 rows=30 loops=1)
-> Index Only Scan using medley_n_idx on medley (cost=0.43..259688.87 rows=10000029 width=4) (actual time=0.013..446.107 rows=5000030 loops=1)
Heap Fetches: 0
-> Index Scan using medley_n_idx on medley t1 (cost=0.43..8.45 rows=1 width=37) (actual time=0.001..0.001 rows=1 loops=30)
Index Cond: (n = medley.n)
Planning time: 0.222 ms
Execution time: 600.607 ms
Если найду в нем баг, с работью пришлю им pull request и заработаю ещё +1 в карму ))