Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #239: query the database in chunks of 200 #271

Merged
merged 2 commits into from
Nov 14, 2012

Conversation

DeepDiver1975
Copy link
Member

Currently the sql query will fail as soon as a certain number of items in the IN condition has been reached.
(1000 for Oracle and sqlite - no idea about the others)
The proposed solution will cut the array into tiny little pieces and execute the statement multiple times.

Fixes #239

My setup: apache + sqlite + all on localhost:

current implementation: 0.1331 sec.
proposal within #329: 0.5020 sec
chunked in packs of 999: 0.3075 sec
chunked in packs of 200: 0.2089 sec

chunk size of 200 gave the best results with my setup

A LIKE based query will not work due to the special case of 'Shared' - afaik

@eMerzh
Copy link
Member

eMerzh commented Nov 6, 2012

Seems good for me... 🐑 it then ;)

@dragotin
Copy link
Contributor

dragotin commented Nov 6, 2012

I dislike your patch, sorry. Doubtless its more performant but it replaces complex and wrong code with more complex code. Of course we now understand it and can read it, but in three weeks from now everybody going through the code will wonder why there is another loop over the chunks.

The target of ownCloud must be to keep code simple IMO. I also doubt that performance improvements on this level for the cost of more complex code make sense for us. There are many other ways to improve performance on higher levels with the database.

@DeepDiver1975
Copy link
Member Author

array_chunk + one foreach is not what I call complex - sorry!

And if we want to simplify code there are other places which deserves it much more.

And finally imagine a folder with 10000 files - we don't want to fire 10000 database queries.

@danimo
Copy link
Contributor

danimo commented Nov 6, 2012

Whatever impl we choose, can we make sure to make this a blocker for 5.0? This looks to me like the DB requires some serious restructuring here.

@blizzz
Copy link
Contributor

blizzz commented Nov 6, 2012

Please add comments which say what is being done and why to solve the readability issue.

@DeepDiver1975
Copy link
Member Author

@blizzz true for sure - thx for the hint
@danimo good luck ;-)

@dragotin
Copy link
Contributor

dragotin commented Nov 6, 2012

@DeepDiver1975 : lol, expected this answer :) Please bear with the simple structured guys like me who like less complex code more because it makes life easier ;-)

BTW - can you easily redo your benchmarking of the solutions with a mysql database backend by chance? Just out of curiosity.

@DeepDiver1975
Copy link
Member Author

@dragotin
I can setup the benchmarking with mysql - but not before tomorrow night - too busy with my real life project ;-)

@tanghus
Copy link
Contributor

tanghus commented Nov 6, 2012

ps aux|grep reallife | awk '{print $2}' | renice -n 19

@scroogie
Copy link

scroogie commented Nov 6, 2012

I actually think that this issue shows a weakness in the database scheme, just as danimo said. It would be fine if shared files wouldn't be an exception. But even in this case, I'd probably do it this way:

  • Introduce an index on propertypath
  • Query the properties with a prefix scan: WHERE propertypath LIKE foo%
  • Add the "special" case of shared files

This will be ugly as well, but it will be easier to remove later on, once the special case of shared files is solved. Also it is easier to read in my opinion, as with the current code you don't even realise that shared files have to be handled differently in this situation.

@bartv2
Copy link
Contributor

bartv2 commented Nov 9, 2012

👍 looks good, simple solution for this bugfix

LukasReschke added a commit that referenced this pull request Nov 14, 2012
fixes #239 - query the database in chunks of 200
@LukasReschke LukasReschke merged commit 8b03b68 into master Nov 14, 2012
@LukasReschke
Copy link
Member

@DeepDiver1975 Feel free to backport :-)

DeepDiver1975 added a commit that referenced this pull request Nov 14, 2012
DeepDiver1975 added a commit that referenced this pull request Nov 16, 2012
@lock lock bot locked as resolved and limited conversation to collaborators Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.5.1a: WebDAV breaks at 999 files per directory
9 participants