Subject | Re: Slower fetchall after creating indices |
---|---|
Author | Ali Gökçen |
Post date | 2006-07-03T11:01:26Z |
Hi Jasper,
building result set by natural scan and sorting in memory operation.
your "where" conditions field unreleted with "order by" field here.
your one page may saves 16 rows or your one row may saving by 16
pages...
Also, how many rows are there?
There is no problem i think..
Regards,
Ali
FFM #208
>no
> Im having a strange problem after i create indices.
>
> Normal situation:
> >>> timeExecute("SELECT Instantie.id FROM Instantie WHERE
> Instantie.deleted=0 ORDER BY Instantie.telefoon ASC", [])
> execute time: 0.56299996376
> >>> a = timeFetchall()
> fetchall time: 0.140999794006
>
> This selects 10.000 records, sorted on column 'telefoon' which has
> index.No index usage,
building result set by natural scan and sorting in memory operation.
>Scan table using telefoon index; indirect full-scan.
> Create an index on telefoon:
> >>> cur.execute("CREATE INDEX temp ON Instantie (telefoon)")
> >>> con.commit()
> >>>
>
> And now i execute the exact same query:
> >>> timeExecute("SELECT Instantie.id FROM Instantie WHERE
> Instantie.deleted=0 ORDER BY Instantie.telefoon ASC", [])
> execute time: 0.0
> >>> b = timeFetchall()
> fetchall time: 0.65700006485
your "where" conditions field unreleted with "order by" field here.
>returns
> The execute time has been reduced a lot, that is what i'd expected.
> But.. the fetchall time is now more than half a second!
>
> Ok.. and to be sure, check if the results are te same:
> >>> a == b
> True
>
> Im really puzzeled by this situation. The fetchall method just
> the data (a list of tuples), which is exactly the same in bothThere
> situations. I can't think of any reason why it could slow down.
> are 10.000 records in the table and it has 55 columns, with 'id' as55 columns? 55* 4 byte fields? or 50*12KB + 5 small fields ?
> primary key with an index on it.
>
> What could be the reason and what could i do to fix this problem?
>
> Thanks in advance,
>
> Jasper Elzinga
>
your one page may saves 16 rows or your one row may saving by 16
pages...
Also, how many rows are there?
There is no problem i think..
Regards,
Ali
FFM #208