Slow query on page creation - Patch

mehmeta - April 22, 2009 - 16:17
Project:Wikitools
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Just made a improvements to a couple queries which reduced the query time from ~5000ms to ~25ms for me. When handling requests, wikitools looks for a page that has the same name, this patch limits that query to the specified wiki nodetypes.

AttachmentSize
wikitoolsPerfPatch.patch1.35 KB

#1

cwgordon7 - May 3, 2009 - 01:10
Status:needs review» needs work

This seems like a good idea, but it is also a minor security hole as the node type names could potentially contain SQL injection text (as I said, minor, because few people can change node type names). Please reroll the patch using db_placeholders() to escape the text properly.

Thanks!

#2

mehmeta - June 29, 2009 - 06:14
Status:needs work» needs review

Here's the updated patch.

AttachmentSize
wikitoolsReqHandlePerfPatch.patch 951 bytes

#3

cwgordon7 - June 29, 2009 - 14:00
Status:needs review» needs work

Thanks, mehmeta!

Just one minor problem - the patch doesn't comply with Drupal's coding standards - we use two spaces for indentation rather than a tab, and leave a space between the concatenation operator (.) and any string encompassed by quotation marks ("string" or 'string' but not $string or get_string()). But just fix that up and it will be ready to commit! Thanks!

#4

mehmeta - July 3, 2009 - 06:00
Status:needs work» needs review

Here's the updated patch, let me know if there are further changes needed, thank you.

AttachmentSize
wikitoolsReqHandlePerfPatch.patch 1.17 KB

#5

cwgordon7 - July 8, 2009 - 06:13
Status:needs review» needs work

Sorry to set this back to needs work, normally I'd just fix the coding standards myself and commit this, but you want to be a maintainer so I'd like you to learn Drupal coding standards yourself for the long term:

- The indentation is off - I don't see why the first three lines should have been touched at all.
- You got the string concatenation rules backwards: you put

<?php
$result
= db_query("SELECT nid, type FROM {node} WHERE type IN (" .db_placeholders($node_types, 'varchar'). ") AND LOWER(title) = LOWER('%s')", $params);
?>

when you should have put

<?php
$result
= db_query("SELECT nid, type FROM {node} WHERE type IN (". db_placeholders($node_types, 'varchar') .") AND LOWER(title) = LOWER('%s')", $params);
?>

Again, sorry to be picky. :( When you make these two changes, however, I will give you commit access, and you'll be free to commit your patch yourself. :) I'm looking forward to having you as a co-maintainer.

#6

mehmeta - July 8, 2009 - 06:40
Status:needs work» needs review

Oh, my bad. Sorry for making this kinda painful.

AttachmentSize
wikitoolsReqHandlePerfPatch.patch 977 bytes

#7

cwgordon7 - July 8, 2009 - 06:42
Status:needs review» reviewed & tested by the community

Beautiful! I've granted you commit access. Thanks so much!

#8

mehmeta - July 10, 2009 - 05:53
Status:reviewed & tested by the community» fixed

thank you, it's committed.

#9

System Message - July 24, 2009 - 06:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.