Re: [SQLObject] Inefficient MultipleJoin
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Charles B. <li...@st...> - 2004-07-18 18:50:49
|
Hi Andrey, > I must admit this way of doing things is terribly unscalable. Isn't it > better to do single "SELECT id, dn, discount, ... FROM customer WHERE > pricing = 4"? Or am I doing something wrong? > I think the behavior that you're observing is in fact the way that SQLObject does things. The reason being if your select were to return thousands of rows of data but you only need the first 10, 10 specific calls would be more efficient than grabbing all 1000 rows. (Especially by reusing the same connection?) I'm no database expert though... From the docs: "Select results are generators, which are lazily evaluated. So the SQL is only executed when you iterate over the select results, or if you use list() to force the result to be executed. When you iterate over the select results, rows are fetched one at a time. This way you can iterate over large results without keeping the entire result set in memory. You can also do things like .reversed() without fetching and reversing the entire result -- instead, SQLObject can change the SQL that is sent so you get equivalent results. You can also slice select results. The results are used in the SQL query, so peeps[:10] will result in LIMIT 10 being added to the end of the SQL query. If the slice cannot be performed in the SQL (e.g., peeps[:-10]), then the select is executed, and the slice is performed on the list of results. This will only happen when you use negative indexes." Hope that helps... -Charles. |