Re: [HACKERS] Reminder: Indices are not used - Mailing list pgsql-hackers

From Vadim B. Mikheev
Subject Re: [HACKERS] Reminder: Indices are not used
Date
Msg-id 352340C6.BF902239@sable.krasnoyarsk.su
Whole thread Raw
In response to Re: [HACKERS] Reminder: Indices are not used  ("Boersenspielteam" <boersenspiel@vocalweb.de>)
Responses Re: [HACKERS] Reminder: Indices are not used
Re: [HACKERS] Reminder: Indices are not used
List pgsql-hackers
Thanks for help!

This is patch for src/backend/optimizer/path/prune.c.
Access pathes of pruned joinrels were not merged and better
pathes were lost, sometimes...

Vadim
*** prune.c.orig    Thu Apr  2 14:56:54 1998
--- prune.c    Thu Apr  2 15:16:17 1998
***************
*** 61,99 ****
  static List *
  prune_joinrel(Rel *rel, List *other_rels)
  {
!     List       *cur = NIL;
!     List       *return_list = NIL;

!     /* find first relation that doesn't match */
!     foreach(cur, other_rels)
      {
!         Rel           *other_rel = (Rel *) lfirst(cur);
!
!         if (!same(rel->relids, other_rel->relids))
!             break;
!     }
!
!     /* we now know cur doesn't match, or is NIL */
!     return_list = cur;
!
!     /*
!      * remove relations that do match, we use lnext so we can remove
!      * easily
!      */
!     while (cur != NIL && lnext(cur) != NIL)
!     {
!         Rel           *other_rel = (Rel *) lfirst(lnext(cur));
!
          if (same(rel->relids, other_rel->relids))
          {
              rel->pathlist = add_pathlist(rel,
                                           rel->pathlist,
                                           other_rel->pathlist);
-             lnext(cur) = lnext(lnext(cur));        /* delete it */
          }
!         cur = lnext(cur);
      }
!     return return_list;
  }

  /*
--- 61,85 ----
  static List *
  prune_joinrel(Rel *rel, List *other_rels)
  {
!     List       *i = NIL;
!     List       *result = NIL;

!     foreach(i, other_rels)
      {
!         Rel       *other_rel = (Rel *) lfirst(i);
!
          if (same(rel->relids, other_rel->relids))
          {
              rel->pathlist = add_pathlist(rel,
                                           rel->pathlist,
                                           other_rel->pathlist);
          }
!         else
!         {
!             result = nconc(result, lcons(other_rel, NIL));
!         }
      }
!     return (result);
  }

  /*

pgsql-hackers by date:

Previous
From: dg@illustra.com (David Gould)
Date:
Subject: Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
Next
From: "Vadim B. Mikheev"
Date:
Subject: Re: [HACKERS] Open 6.3.1 issues