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

Sqltap showing incorrect "Query Count" in certain cases #42

Open
dwaltrip opened this issue Jul 2, 2019 · 0 comments
Open

Sqltap showing incorrect "Query Count" in certain cases #42

dwaltrip opened this issue Jul 2, 2019 · 0 comments

Comments

@dwaltrip
Copy link

dwaltrip commented Jul 2, 2019

sqltap incorrect query count

Sqltap is showing that only a single query was performed, when it fact 43 were.

If I set echo=True for sqlalchemy, the relevant output is:

2019-07-01 16:35:48,649 INFO sqlalchemy.engine.base.Engine DELETE FROM master_steps WHERE master_steps.id = %(id)s
2019-07-01 16:35:48,649 INFO sqlalchemy.engine.base.Engine ({'id': 13701}, {'id': 13702}, {'id': 13703}, {'id': 13704}, {'id': 13705}, {'id': 13706}, {'id': 13707}, {'id': 13708}  ... displaying 10 of 43 total bound parameter sets ...  {'id': 13742}, {'id': 13743})

Turning on postgres logging, we see the actual queries (this was from a different run than the above example with echo=True, so the times and ids are different):

2019-07-01 17:07:34.522 PDT [83440] LOG:  statement: DELETE FROM master_steps WHERE master_steps.id = 39873
2019-07-01 17:07:34.540 PDT [83440] LOG:  statement: DELETE FROM master_steps WHERE master_steps.id = 39874
... (repeat for all bound parameter sets)

The last bound parameter set is the one being shown in sqltap. Based on the timings from the postgres logs, it looks like the "Total time" shown is the correct value for the sum of all the query times. But the mean, median, max, etc are not correct. And the "Query Count" is not correct.

In case it is helpful, here is what the application code looks like (roughly):

for step in steps:
      db_session.delete(step)

# other logic unrelated to steps...

db_session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant