-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
v.db.join: speed up processing by using fewer db.execute commands #3286
Conversation
The problem with Lines 189 to 191 in ea8f3ea
Line 142 in ea8f3ea
This line truncates the SQL string to 8206 chars. Line 196 in ea8f3ea
Example of long SQL string:
sql = "CREATE TABLE soils_test (cat integer, soiltype varchar(10)"
for i in range(1200):
sql += f", soiltype{i} varchar(10)"
sql += ")"
For this long SQL string, it is better to use read SQL string from the file |
Thanks! I now updated both
instead of having just one |
Probably a set of SQL commands should be wrapped into a TRANSACTION?
Random example: grass/scripts/v.dissolve/v.dissolve.py Line 200 in 24365e1
|
Thanks! Adding this to both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First I appologize for long delay.
Looks good to me. I tested this fix with adding 500 columns and time was reduced from approximately 1 minute to 0.721s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, impressive speed-up!
This PR speeds up
v.db.join
for large tables. Previously, individualv.db.addcolumn
anddb.execute
commands were run for each column to join.This PR alters
v.db.addcolumn
andv.db.join
such that only onedb.execute
command is executed for each, using a temporary sql_file instead of stdin as input for the SQL statement.Previous approach (deprecated):
~~In this PR, one single
v.db.addcolumn
anddb.execute
command is executed for a chunk of max 100 columns at once.Here, all individual
v.db.addcolumn
commands are grouped into one single command. Additionally, alldb.execute UPDATE table...
commands to add data to the new columns are grouped into a single command. As the SQL command may become very long this way (andincomplete input in sqlite3_prepare()
errors may be encountered, see also #3273), commands with a total string length of > ~10.000 are again split into individualSQL UPDATE
commands.~~