Re: [PATCHES] Bitmap index scan preread using posix_fadvise (Was: There's random access and then there's random access)

2008-02-02 Thread Luke Lonergan
Nice!

- Luke


On 1/30/08 9:22 AM, Gregory Stark [EMAIL PROTECTED] wrote:

 
 Here's the WIP patch for doing prereading when doing bitmap index scans.
 
 I was performance testing it as I was developing it here:
 
 http://archives.postgresql.org/pgsql-hackers/2007-12/msg00395.php
 
 Note that this only kicks in for bitmap index scans which are kind of tricky
 to generate. I used the attached function to generate them in the post above.
 
 Also note I wouldn't expect to see much benefit unless you're on a raid array,
 even a small one. But if you are on a raid array then the benefit should be
 immediately obvious or else posix_fadvise just isn't working for you. I would
 be interested in hearing on which OSes it does or doesn't work.
 
 *If* this is the approach we want to take rather than restructure the buffer
 manager to avoid taking two trips by marking the buffer i/o-in-progress and
 saving the pinned buffer in the bitmap heap scan then this is more or less in
 final form. Aside from some autoconf tests and the documentation for the GUC I
 think it's all in there.
 
 


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[PATCHES] Proposed patch for bug #3921

2008-02-02 Thread Tom Lane
Attached is a proposed patch for bug #3921, which complained that CREATE
TABLE LIKE INCLUDING INDEXES fails inappropriately for non-superusers.

There are two parts to the patch: the first follows Greg Starks' opinion
that explicitly specifying the current database's default tablespace
shouldn't be an error at all, and so the permissions checks during
table/index creation are suppressed when tablespaceId ==
MyDatabaseTableSpace.  (Note that the assign hooks for
default_tablespace and temp_tablespaces already behaved this way, so we
were not exactly being consistent anyhow.)  I couldn't find anyplace in
the documentation that specifies the old behavior, so no docs changes.

The second part fixes the LIKE INCLUDING INDEXES code to default the
index tablespace specification when the source index is in the
database's default tablespace.  This would provide an alternative
way of fixing the bug if anyone doesn't like the first part.  With the
first part it's redundant, but seems worth doing anyway to avoid the
overhead of looking up the tablespace name and then converting it back
to OID in the typical case.

Also there is a correction of an obsolete comment in parsenodes.h, which
should be applied in any case.

An issue that this patch doesn't address is what happens if the source
index is in a non-default tablespace that the current user does not have
CREATE permission for.  With both current CVS HEAD and this patch, that
will result in an error.  Is that okay?  We could imagine making
parse_utilcmd.c check the permissions and default the tablespace
specification if no good, but that behavior seems a bit peculiar to me.
Command semantics don't normally change based on whether you have
permissions or not.

An entirely different tack we could take is to adopt the position
that LIKE INCLUDING INDEXES shouldn't copy index tablespaces at all,
but I didn't hear anyone favoring that approach in the bug discussion.

regards, tom lane

Index: src/backend/commands/indexcmds.c
===
RCS file: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v
retrieving revision 1.170
diff -c -r1.170 indexcmds.c
*** src/backend/commands/indexcmds.c9 Jan 2008 21:52:36 -   1.170
--- src/backend/commands/indexcmds.c3 Feb 2008 02:32:14 -
***
*** 215,221 
}
  
/* Check permissions except when using database's default */
!   if (OidIsValid(tablespaceId))
{
AclResult   aclresult;
  
--- 215,221 
}
  
/* Check permissions except when using database's default */
!   if (OidIsValid(tablespaceId)  tablespaceId != MyDatabaseTableSpace)
{
AclResult   aclresult;
  
Index: src/backend/commands/tablecmds.c
===
RCS file: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v
retrieving revision 1.241
diff -c -r1.241 tablecmds.c
*** src/backend/commands/tablecmds.c30 Jan 2008 19:46:48 -  1.241
--- src/backend/commands/tablecmds.c3 Feb 2008 02:32:15 -
***
*** 340,346 
}
  
/* Check permissions except when using database's default */
!   if (OidIsValid(tablespaceId))
{
AclResult   aclresult;
  
--- 340,346 
}
  
/* Check permissions except when using database's default */
!   if (OidIsValid(tablespaceId)  tablespaceId != MyDatabaseTableSpace)
{
AclResult   aclresult;
  
Index: src/backend/executor/execMain.c
===
RCS file: /cvsroot/pgsql/src/backend/executor/execMain.c,v
retrieving revision 1.302
diff -c -r1.302 execMain.c
*** src/backend/executor/execMain.c 1 Jan 2008 19:45:49 -   1.302
--- src/backend/executor/execMain.c 3 Feb 2008 02:32:15 -
***
*** 2594,2600 
}
  
/* Check permissions except when using the database's default space */
!   if (OidIsValid(tablespaceId))
{
AclResult   aclresult;
  
--- 2594,2600 
}
  
/* Check permissions except when using the database's default space */
!   if (OidIsValid(tablespaceId)  tablespaceId != MyDatabaseTableSpace)
{
AclResult   aclresult;
  
Index: src/backend/parser/parse_utilcmd.c
===
RCS file: /cvsroot/pgsql/src/backend/parser/parse_utilcmd.c,v
retrieving revision 2.8
diff -c -r2.8 parse_utilcmd.c
*** src/backend/parser/parse_utilcmd.c  1 Jan 2008 19:45:51 -   2.8
--- src/backend/parser/parse_utilcmd.c  3 Feb 2008 02:32:15 -
***
*** 767,773 
index = makeNode(IndexStmt);
index-relation = cxt-relation;
index-accessMethod = pstrdup(NameStr(amrec-amname));
!   index-tableSpace =