Re: Drupal and PostgreSQL - performance issues? - Mailing list pgsql-general

From Tomasz Ostrowski
Subject Re: Drupal and PostgreSQL - performance issues?
Date
Msg-id 48F75D20.2070908@batory.org.pl
Whole thread Raw
In response to Re: Drupal and PostgreSQL - performance issues?  (Stephen Frost <sfrost@snowman.net>)
List pgsql-general
On 2008-10-16 16:40, Stephen Frost wrote:

>> There is an issue report with lengthy discussion on drupal.org:
>> http://drupal.org/node/196862
>> And a proposed patch:
>
> I don't see 'limit 1' anywhere in that patch..

Sorry - haven't checked it - I have checked only a 6.x version
http://drupal.org/files/issues/drupal_lookup_path-6.x.patch.txt
which is sane. This Earnie guy, the author, made a mistake in 5.x version.

I've corrected 5.x based on 6.x. I've attached it. Maybe this time I'll
get this right.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
                                                       Winnie the Pooh
Index: path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.13
diff -u -p -r1.13 path.inc
--- path.inc    23 Dec 2006 22:04:52 -0000    1.13
+++ path.inc    4 Dec 2007 21:04:51 -0000
@@ -42,18 +42,18 @@ function drupal_init_path() {
 function drupal_lookup_path($action, $path = '') {
   // $map keys are Drupal paths and the values are the corresponding aliases
   static $map = array(), $no_src = array();
-  static $count;
+  static $have_rows;

   // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
-  if (!isset($count)) {
-    $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
+  if (!isset($have_rows)) {
+    $have_rows = db_result(db_query('SELECT pid FROM {url_alias} LIMIT 1'));
   }

   if ($action == 'wipe') {
     $map = array();
     $no_src = array();
   }
-  elseif ($count > 0 && $path != '') {
+  elseif ($have_rows && $path != '') {
     if ($action == 'alias') {
       if (isset($map[$path])) {
         return $map[$path];

pgsql-general by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Drupal and PostgreSQL - performance issues?
Next
From: Tom Lane
Date:
Subject: Re: PQescapestringConn not found in libpq.dll