Just trying to read first row in table based on index, pg scans and sorts instead?
От | johnmudd |
---|---|
Тема | Just trying to read first row in table based on index, pg scans and sorts instead? |
Дата | |
Msg-id | 1334871695398-5652859.post@n5.nabble.com обсуждение исходный текст |
Ответы |
Re: Just trying to read first row in table based on index, pg scans and sorts instead?
|
Список | pgsql-novice |
I populated my table, then added the following index. I want to read the first row based on this index but it takes 3 seconds to get the result. I hope there's a way to improve this, possibly take advantage of the index. Index: "rx_storenbr_rxnbr_rfnbr_index" UNIQUE, btree (storenbr, rxnbr, rfnbr) reports=> EXPLAIN ANALYZE SELECT * FROM rx ORDER BY (storenbr,rxnbr,rfnbr) LIMIT 1; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------- Limit (cost=24935.26..24935.27 rows=1 width=828) (actual time=3179.721..3179.721 rows=1 loops=1) -> Sort (cost=24935.26..25399.14 rows=185551 width=828) (actual time=3179.719..3179.719 rows=1 loops=1) Sort Key: (ROW(storenbr, rxnbr, rfnbr)) Sort Method: top-N heapsort Memory: 18kB -> Seq Scan on rx (cost=0.00..24007.51 rows=185551 width=828) (actual time=0.038..1094.316 rows=185551 loops=1) Total runtime: 3179.986 ms (6 rows) reports=> reports=> select version(); version ------------------------------------------------------------------------------------------------------ PostgreSQL 9.1.2 on i686-pc-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5, 32-bit (1 row) -- View this message in context: http://postgresql.1045698.n5.nabble.com/Just-trying-to-read-first-row-in-table-based-on-index-pg-scans-and-sorts-instead-tp5652859p5652859.html Sent from the PostgreSQL - novice mailing list archive at Nabble.com.
В списке pgsql-novice по дате отправления: