On Fri, 24 Oct 2003, Staff, Alexander wrote:
> Hi,
> I created a simple table (name char200, zip char10, city char200, street char200, id
> int) and filled some data, appr. 250 000 records, in it.
> I tested accessing some rows (select id from address where id = 4;, select *
> from address w
(Sorry for reposting...)
> You said you enter some rows, but how many rows got returned by your
query?
You're right, it does make all the difference. With only a few rows,
indexing is somehow used in the first case only (for my example), but with
larger tables index scan is used in both ways.
What does your data look like? If you have a lot of duplicate id's, a
sequential scan may be better than an index scan.
If you are not sure if this is the case, try:
SELECT id, count(*) AS count FROM test GROUP BY id ORDER BY count DESC
LIMIT 50;
This should show you the top 50 most duplicate