Comments

berdir’s picture

Assigned: Unassigned » berdir

I need to learn DBTNG anyway, so I've started this one..

It has some tricky parts in it, so I might have to ping you on IRC.

berdir’s picture

Status: Active » Needs review
StatusFileSize
new14.76 KB

Attached is a first patch, some notes..

- there is only a single insert query and because of that, there is only a single place where delay() can be used
- I followed the newly proposed style for extenders at #425872: DX problem with DB extenders
- That module has *a lot* complex queries with functions, group by, custom count queries and unfortunatly, not so many tests. All queries seem to work but someone with more experience with DBTNG needs to review them carefully :)
- Is there a rule when to use dynamic and when static queries? I converted all calls to dynamic queries but there are a few simple queries that should maybe be static ones.

Crell’s picture

Status: Needs review » Needs work

Dynamic queries should be used if and only if:

- The query itself is conditional and changes based on user input or similar.
- You need to flag it for node access or some other query_alter operation.
- You need to use an extender for a pager, tablesort, etc.

If you can make it static, do so. That's going to be faster and simpler.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new14.63 KB

Ok.

Converted 3 queries or so back to static. Everything else in that module uses Pager.

berdir’s picture

StatusFileSize
new15.96 KB

Updated based on Crell's feedback at #394476-1: DBTNG: Menu module: Converted all db_*() calls which have more than one chained method call to multi-line.

dave reid’s picture

Status: Needs review » Needs work

I don't see any explanation so far in the issue as to why we're adding ->delay() to this query:

-    db_insert('accesslog')->fields(array(
-      'title' => strip_tags(drupal_get_title()),
-      'path' => $_GET['q'],
-      'url' => $_SERVER['HTTP_REFERER'],
-      'hostname' => ip_address(),
-      'uid' => $user->uid,
-      'sid' => session_id(),
-      'timer' => (int) timer_read('page'),
-      'timestamp' => REQUEST_TIME,
-    ))->execute();
+    db_insert('accesslog')
+      ->fields(array(
+        'title' => strip_tags(drupal_get_title()),
+        'path' => $_GET['q'],
+        'url' => $_SERVER['HTTP_REFERER'],
+        'hostname' => ip_address(),
+        'uid' => $user->uid,
+        'sid' => session_id(),
+        'timer' => (int) timer_read('page'),
+        'timestamp' => REQUEST_TIME,
+      ))
+      ->delay()
+      ->execute();

Double check the coding standards, there are multiple instances of foreach(...) instead of foreach (...). There should always be a space between control structures and their expressions.

berdir’s picture

StatusFileSize
new15.95 KB

Hm. I added the delay() call because Crell mentioned it and I thought that it does make sense. However, after reading http://dev.mysql.com/doc/refman/5.1/en/insert-delayed.html, I'm not so sure anymore..

- It's not supported for InnoDB
- It's actually slower than a normal INSERT, especially when the table is not in use. According to the documentation, you should only use it on a table where you run *very* long SELECT/UPDATE
- I've no idea how it's handled by other DBMS (if at all)

Because of that, I removed it again. Coding style corrections (compared to the examples at http://drupal.org/node/310079) are still part of that patch

Another changes:
- fixed the foreach's
- fixed the query in statistics_title_list, that was broken in many ways ;)

#160226: SQL in statistics_node_tracker function is wrong should imho be re-rolled after this gets in.

berdir’s picture

There is still something wrong with the statistics_title_list query, need to resolve that first.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new15.93 KB

I have to use range() instead of Pager and limit() as the blocks don't use a pager...

dries’s picture

I reviewed this patch and it looked good to me so I committed it to CVS HEAD. We can re-open the issue if necessary.

Thanks Berdir!

dawehner’s picture

Status: Needs review » Fixed

so this should be marked as fixed :)

Status: Fixed » Closed (fixed)
Issue tags: -DBTNG Conversion

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