1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| mydb=# explain analyze with cte as(select data_id,create_time from test_table where status=0 and city_id=310188 and type=103 and sub_type=any(array[10306,10304,10305]) order by create_time desc) mydb-# select * from cte limit 1; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=4651.95..4651.97 rows=1 width=16) (actual time=0.093..0.093 rows=1 loops=1) CTE cte -> Sort (cost=4648.95..4651.95 rows=1199 width=16) (actual time=0.090..0.090 rows=1 loops=1) Sort Key: test_table.create_time Sort Method: quicksort Memory: 25kB -> Bitmap Heap Scan on test_table (cost=25.61..4587.64 rows=1199 width=16) (actual time=0.048..0.078 rows=15 loops=1) Recheck Cond: ((city_id = 310188) AND (sub_type = ANY ('{10306,10304,10305}'::integer[])) AND (type = 103) AND (status = 0)) Heap Blocks: exact=11 -> Bitmap Index Scan on test_table_city_id_sub_type_create_time_idx (cost=0.00..25.31 rows=1199 width=0) (actual time=0.041..0.041 rows=15 loops=1) Index Cond: ((city_id = 310188) AND (sub_type = ANY ('{10306,10304,10305}'::integer[]))) -> CTE Scan on cte (cost=0.00..23.98 rows=1199 width=16) (actual time=0.092..0.092 rows=1 loops=1) Planning time: 0.476 ms Execution time: 0.132 ms (13 rows)
|