Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Watchdog has 2 instances of the uid column when using this query:
SELECT w.*, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid;
Patch updates this query to:
SELECT w.severity, w.type, w.timestamp, w.message, w.link, u.name FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid
The columns are enumerated because its generally good practice in high performance SQL coding to enumerate your columns (no matter how many) so the database doesn't have to do a call to its system table to review all the columns in the tables and their types and act accordingly. By enumerating, it grabs the column by index (hash prob.) from the system table which contains the column name, type.
Comment | File | Size | Author |
---|---|---|---|
#3 | watchdog_sql_cleanup_1.patch | 1.03 KB | Souvent22 |
#2 | watchdog_sql_cleanup_0.patch | 856 bytes | Souvent22 |
watchdog_sql_cleanup.patch | 849 bytes | Souvent22 | |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedthe nwe query omits *both* uid columns. is that intended. if so, this is a reasonable change.
Comment #2
Souvent22 CreditAttribution: Souvent22 commentedThanks. You're right, it does omit both..as it should..however, I DID forget the wid column. Re-rolled patch.
I looked through the code ( which is quoted below for easy review), and uid is not used anywhere.
Comment #3
Souvent22 CreditAttribution: Souvent22 commentedJust reviewed and tested the patch. uid is used in the theme('username', $obj) function. w/o uid, it will still display the username, but withe a (not verified) clause. Fixed with this patch. that should be it.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commenteduid is needed by this line: theme('username', $watchdog). after that, looks RTBC to me.
Comment #5
m3avrck CreditAttribution: m3avrck commentedSeems Souvent22 and Moshe cross posted each other.
Comment #6
m3avrck CreditAttribution: m3avrck commentedAlso as a note, we should look into carrying this practice throughout core (more small patches like this that are easy to digest) and updating the coding guidelines. Seems like a nice and easy small performance gain.
Comment #7
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #8
(not verified) CreditAttribution: commented