Re: [ib-support] Select count(*) slow even with index?
Author
Kenneth Foo
Post date
2002-03-19T11:07:52Z
----- Original Message -----
From: "Helen Borrie" <helebor@...>
To: <ib-support@yahoogroups.com>
Sent: Tuesday, March 19, 2002 6:40 PM
Subject: Re: [ib-support] Select count(*) slow even with index?
> >A normal index is created on FOLDER_ID. There aren't many FOLDER_ID
values
> >around
> >(probably about 10), so I'm not sure if indexing this field is a good
> >idea. (Is it?).
>
> Probably not. You would likely be better to remove that index and replace
> it with one on (FOLDER_ID,PRI_KEY) to improve the selectivity.
Thanks. I found the reason why the query was slow (it's in another post).
Basically, FOLDER_ID is a NUMERIC(18,0) column, but I did a select
using '999' instead of 999. Somehow, IB seemed to perform redundant
data type conversion (I think).
But would this actually help if I performed a query like
SELECT * FROM MESSAGES WHERE FOLDER_ID=999; ?
(Or would it help inserts instead?)
I plan to have a table that run into 2 or 3 millions records.
However, a majority of these records will have FOLDER_ID=10,
for example. (I need to classify records into few group)