Fast lookup of bulky "table"

Peter J. Holzer hjp-python at hjp.at
Mon Jan 16 14:32:16 EST 2023


On 2023-01-15 18:06:36 -0500, Thomas Passin wrote:
> You especially want to avoid letting the database engine do full-table
> scans over and over. And you never want to send a lot of rows to
> Python and do post-filtering on them if you can avoid it.

Another thing to avoid: Lots of small queries. If you have the choice
between a single query which returns 10000 rows and 1000 queries which
return on average 5 rows each, the former is almost always much faster.
Each query carries some overhead. This may not be very noticeable with
SQLite (as everything is in the same process), but it becomes more and
more pronounced the farther the database is from the client. For
complicated queries the parsing and planning overhead can also become
significant.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20230116/a3e02947/attachment.sig>


More information about the Python-list mailing list