|Subject||Re: [ib-support] Select count(*) slow even with index?|
> I have roughly 20,000 items in the database. A large bulk of them have aFOLDER_ID of '999'
> (about 19000 of them).around
> Query like this takes 8 seconds to complete (!)
> SELECT COUNT(*) FROM MESSAGES WHERE FOLDER_ID='999';
> Whereas, a query like this completes in a split second.
> SELECT FOLDER_ID,COUNT(FOLDER_ID) FROM MESSAGES GROUP BY FOLDER_ID;
> A normal index is created on FOLDER_ID. There aren't many FOLDER_ID values
> (probably about 10), so I'm not sure if indexing this field is a goodidea. (Is it?).
> Both queries plans seem to be using the index that I created. (That's what
> But why is the first query so much slower?FOLDER_ID='999' ?
> What are the workarounds if I wish to count the number of rows having
> I need to get a really fast count of records as I perform this query quiteoften.
>I have a similar query: select count(id) from detail2
Table detail2 has 250000 records and the query takes 18seconds to complete.
Id is the
I also tried this with postgreSQL (for comparing reasons) and it takes 9
seconds. Same table,
Pirtea Calin Iancu
S.C. SoftScape S.R.L.