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

Remove newlines from queries in execute_query() (Trac #2591) #2591

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 9 comments
Closed

Remove newlines from queries in execute_query() (Trac #2591) #2591

elgg-gitbot opened this issue Feb 16, 2013 · 9 comments
Labels
Milestone

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/2591 on 40821031-04-07 by brettp, assigned to unknown.

Elgg version: 1.7

Multiple line queries are nice for writing, but make grepping through logs painful.

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.8.1 by cash on 40894706-07-16

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.8 by cash on 41235107-03-10

@elgg-gitbot
Copy link
Author

cash wrote on 41235121-10-30

(In [svn:8869]) Fixes #2591 removing newlines in queries - thanks to Tachyon

@elgg-gitbot
Copy link
Author

trac user hellekin wrote on 41273249-01-18

Wow, wait a minute!

  • You're adding a preg_replace to a function that's used often, just to have pretty logs? That's just plain wrong.
  • Replacing CRLF by nothing will break the SQL and allow joining words: isn't that a space you want there?

This "fix" should belong to a log filter, post execution of the SQL: you don't want free bloat, and MySQL will interpret the nicely written query.

@elgg-gitbot
Copy link
Author

brettp wrote on 41275097-09-16

This "fix" should belong to a log filter, post execution of the SQL: you don't want free bloat, and MySQL will interpret the nicely written query.

The removal is for both MySQL logs (which still show the \n) AND the debug log, so it needs to be done pre-execution.

@elgg-gitbot
Copy link
Author

cash wrote on 41275111-05-04

Regarding execution speed, I did some profiling before accepting the patch and this does not add additional time to page creation (that can be measured). If we were doing a 1000 queries per page, it would add a few milliseconds.

Replacing with a space is a valid point. It shouldn't be an issue because we always indent the lines of the query, but it wouldn't hurt.

@elgg-gitbot
Copy link
Author

cash wrote on 41367955-04-14

(In [svn:9067]) Refs #2591 we were not logging inserts, updates, and deletes. Also logging was happening before formatting of the queries. All fixed in this commit.

@elgg-gitbot
Copy link
Author

cash wrote on 41367964-08-18

Fixed the spaces issue also with [svn:9067].

Whether we do this only when logging or for all queries, we're talking about microseconds. I'm fine with only doing it for Elgg logging only since the only time I look at MySQL logs is for slow queries and it is easy to post process those logs. Don't know about other devs.

I'm going to close this for now. We can also reopen if disagreement or something really odds happens and it does affect performance.

@elgg-gitbot
Copy link
Author

cash wrote on 41862123-09-13

Fixes #4071 hellekin was right - it was a bad idea to format queries

Changeset: [8cca602e2bc1c65b99a2d0c2a60255ab09ca4f3d]

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

No branches or pull requests

1 participant