| От | Stephan Szabo |
|---|---|
| Тема | Re: "select count(*) from contacts" is too slow! |
| Дата | |
| Msg-id | 20031007114534.T53246@megazone.bigpanda.com обсуждение исходный текст |
| Ответ на | "select count(*) from contacts" is too slow! (Paul Serby <paul.serby@clockltd.com>) |
| Список | pgsql-general |
On Tue, 7 Oct 2003, Paul Serby wrote: > Why does '*select count(id) from "tblContacts"'* do a sequential scan > when the field '*id*' is indexed using a btree? > > MySql simply looks at the index which is keeping a handy record of the > number of rows. > > Can anybody explain how and why postgres does this query like it does? Because the index doesn't contain enough information to determine if a particular row is visible to your transaction or not. It would have to go read the table to find that out, at which point using the index doesn't help. There's been a recent discussion of this on one of the lists (either -general or -performance I'd guess) that you might want to look up in the archives.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера