相关疑难解决方法(0)

4300 万张 PostgreSQL 表上的复合索引

这个问题与我之前问过的问题有关:PostgreSQL 中复合索引中的列顺序(和查询顺序)

我想我可以在这里尖锐和限制我的问题,而不是超载这个问题。鉴于以下查询(和 EXPLAIN ANALYZE),我正在创建的复合索引有帮助吗?

第一个查询仅使用简单索引(大纲上的 GIST)和(pid 上的 BTREE)运行。

查询是:

EXPLAIN ANALYZE SELECT DISTINCT ON (path) oid, pid, product_name, type, path, size 
FROM portal.inventory AS inv 
WHERE ST_Intersects(st_geogfromtext('SRID=4326;POLYGON((21.51947021484375 51.55059814453125, 18.9129638671875 51.55059814453125, 18.9129638671875 48.8287353515625, 21.51947021484375 48.8287353515625, 21.51947021484375 51.55059814453125))'), inv.outline) 
AND (inv.pid in (20010,20046)) 
Run Code Online (Sandbox Code Playgroud)

——

结果如下(速度更快,但也许这只是因为数据库是热的)。

"Unique  (cost=581.76..581.76 rows=1 width=89) (actual time=110.436..110.655 rows=249 loops=1)"
"  ->  Sort  (cost=581.76..581.76 rows=1 width=89) (actual time=110.434..110.477 rows=1377 loops=1)"
"        Sort Key: path"
"        Sort Method: quicksort  Memory: 242kB"
"        ->  Bitmap Heap Scan on inventory …
Run Code Online (Sandbox Code Playgroud)

postgresql index index-tuning

4
推荐指数
1
解决办法
535
查看次数

标签 统计

index ×1

index-tuning ×1

postgresql ×1