Convert string to command..

sjdevnull at yahoo.com sjdevnull at yahoo.com
Thu Oct 18 16:09:36 EDT 2007


On Oct 18, 1:38 pm, Bruno Desthuilliers <bruno.
42.desthuilli... at wtf.websiteburo.oops.com> wrote:
> Abandoned a écrit :
> (snip)
>
> > I'm very confused :(
> > I try to explain main problem...
> > I have a table like this:
> > id-1 | id-2 | value
> > 23     24       34
> > 56     68       66
> > 56     98       32455
> > 55     62       655
> > 56     28       123
> > .... ( 3 millions elements)
>
> > I select where id=56 and 100.000 rows are selecting but this took 2
> > second. (very big for my project)
>
> Not to bad in the absolute.
>
> > I try cache to speed up this select operation..
> > And create a cache table:
> > id-1 | all
> > 56    {68:66, 98:32455, 62:655}
>
> I really doubt this is the right way to go.
>
> > When i select where id 56 i select 1 row and its took 0.09 second but
> > i must convert text to dictionary..
>
> > Have you got any idea what can i do this conver operation ?
>
> Other alread answered
>
> > Have you got any idea what can i do cache for this table ?
>
> Depends on your RDBMS. And as far as I'm concerned, I'd start by trying
> to find out how to optimize this query within the RDBMS - good ones are
> usually highly optimized softwares with provision for quite a lot of
> performance tuning.

Just the overhead of the query is a killer compared to a dictionary
lookup in Python, even if all you're doing is selecting an integer
from a 1-row, 1-column table.

Usually you can get around that by making a single query to return all
of your results (or a handful of queries), but occasionally it just
doesn't matter how fast the DB can get to the data--the simple act of
asking it is slow enough on its own.




More information about the Python-list mailing list