Better Performance when fetching objects from DB #29

Merged
merged 1 commit into from Mar 10, 2012

Conversation

Projects
None yet
2 participants
Contributor

christoph-buente commented Feb 3, 2012

Hi,

when using big_sitemap the SQL Queries for fetching the objects from the db would concatenate the WHERE conditions from the query before. This looks something like this:

SELECT * FROM table WHERE ((table.id > 11439258) AND (table.id > 15757399) AND ...
SELECT * FROM table WHERE ((table.id > 11439258) AND (table.id > 15757399) AND AND (table.id > 16456399) ...

And so on, this causes an endless db query wich takes longer and longer for large object counts.

With my fix it looks like this:

SELECT * FROM table WHERE ((table.id > 181306845)) LIMIT 1001
SELECT * FROM table WHERE ((table.id > 186953272)) LIMIT 1001

All test are running. Would be cool, if you could merge it in. I'm using ruby 1.8.7 and MySQL 5.5

Cheers, Christoph

@alexrabarts alexrabarts added a commit that referenced this pull request Mar 10, 2012

@alexrabarts alexrabarts Merge pull request #29 from sozialhelden/master
Better Performance when fetching objects from DB
ca8b929

@alexrabarts alexrabarts merged commit ca8b929 into alexrabarts:master Mar 10, 2012

Owner

alexrabarts commented Mar 10, 2012

Thanks for the patch. Please note, BigSitemap's responsibilities for querying the database have been deprecated in favour of the new block syntax, which I recommend you switch to if possible (see the README.md for details of the new syntax).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment