Search optimisation
От | Olwen Williams |
---|---|
Тема | Search optimisation |
Дата | |
Msg-id | 3856E044.21391F03@ihug.co.nz обсуждение исходный текст |
Ответы |
Re: [SQL] Search optimisation
|
Список | pgsql-sql |
I'm new to SQL databases although I've worked a lifetime on PICK type systems. I'm having trouble gettting selects to work well. I have a database with a number of tables. I'm having a number of problems one is this: This query runs very quickly and returns one row: select * from biblioitems where isbn='031051911X'; explanation: Index Scan using isbnidx on biblioitems (cost=203.35 rows=2988 width=102) This is fast: select * from biblioitems,items,biblio where biblioitems.biblionumber ='109' and biblioitems.biblionumber = items.biblionumber and biblio.biblionumber = biblioitems.biblionumber explanation: Nested Loop (cost=54.91 rows=657 width=340) -> Nested Loop (cost=4.08 rows=2 width=167) -> Index Scan using bibitbnoidxon biblioitems (cost=2.03 rows=1 width=102) -> Index Scan using bibnumidx on biblio (cost=2.05 rows=59945 width=65) -> Index Scan using bibnumitem on items (cost=25.42 rows=73185 width=173) This one is slow: select * from biblioitems,items,biblio where isbn='031051911X' and biblioitems.biblionumber = items.biblionumber and biblio.biblionumber = biblioitems.biblionumber; explanation:Hash Join (cost=11830.17 rows=981357 width=340) -> Seq Scan on items (cost=4158.10 rows=73185 width=173) -> Hash (cost=5091.33 rows=2989 width=167) -> Hash Join (cost=5091.33 rows=2989 width=167) -> Seq Scanon biblio (cost=2767.19 rows=59945 width=65) -> Hash (cost=203.35 rows=2988 width=102) -> Index Scan using isbnidx on biblioitems (cost=203.35 rows=2988 width=102) How can I make this query use the indexes?
В списке pgsql-sql по дате отправления: