Skip to content
New issue

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

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

Already on GitHub? # to your account

Logging: Multiple logs for a single query #5

Closed
cvburgess opened this issue Nov 23, 2018 · 0 comments · Fixed by #6
Closed

Logging: Multiple logs for a single query #5

cvburgess opened this issue Nov 23, 2018 · 0 comments · Fixed by #6
Labels
bug Something is broken or not as expected help wanted Great issue to grab, help is appreciated!

Comments

@cvburgess
Copy link
Owner

We are currently using https://github.com/khmm12/knex-tiny-logger for optional query logging but it does not seem to be working correctly. When making a single trip to the PostgreSQL database, it appears that multiple logs are created and the number per query goes up with every request. When logging the actual PostgreSQL database, it was verified that only a single request to the database is made.

TinyLogger Output:

SQL (5.926 ms) select * from "tablename1" where "username" = '--username--'
SQL (5.926 ms) select * from "tablename1" where "username" = '--username--'
SQL (5.926 ms) select * from "tablename1" where "username" = '--username--'
SQL (3.081 ms) select * from "tablename2"
SQL (3.081 ms) select * from "tablename2"
SQL (6.299 ms) select * from "tablename3" where "user_id" = 234
SQL (7.602 ms) select * from "tablename3" where "user_id" = 234
SQL (7.602 ms) select * from "tablename3" where "user_id" = 234
SQL (7.602 ms) select * from "tablename3" where "user_id" = 234
SQL (9.030 ms) select * from "tablename4" where "id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.189 ms) select * from "tablename5" where "tsg_id" in (1)
SQL (7.389 ms) select * from "tablename6" where "id" = 2
SQL (7.808 ms) select * from "tablename6" where "id" = 2

PostgreSQL Logs:

LOG:  execute <unnamed>: select * from "tablename1" where "username" = '--username--'
LOG:  execute <unnamed>: select * from "tablename2"
LOG:  execute <unnamed>: select * from "tablename3" where "user_id" = 234
LOG:  execute <unnamed>: select * from "tablename4" where "id" in (1)
LOG:  execute <unnamed>: select * from "tablename5" where "tsg_id" in ($1)
LOG:  execute <unnamed>: select * from "tablename6" where "id" = 2

TinyLogger uses the .on method of knex - I'm not entirely sure if this is an issue with TinyLogger, Knex, or SQLDataSource.

@cvburgess cvburgess added bug Something is broken or not as expected help wanted Great issue to grab, help is appreciated! labels Nov 23, 2018
cvburgess added a commit that referenced this issue Nov 29, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something is broken or not as expected help wanted Great issue to grab, help is appreciated!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant