You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hawq.apache.org by "Ruilong Huo (JIRA)" <ji...@apache.org> on 2016/03/28 04:33:25 UTC
[jira] [Closed] (HAWQ-588) Improve performance for truncate with
small table
[ https://issues.apache.org/jira/browse/HAWQ-588?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ruilong Huo closed HAWQ-588.
----------------------------
> Improve performance for truncate with small table
> -------------------------------------------------
>
> Key: HAWQ-588
> URL: https://issues.apache.org/jira/browse/HAWQ-588
> Project: Apache HAWQ
> Issue Type: Improvement
> Components: Query Execution
> Affects Versions: 2.0.0-beta-incubating
> Reporter: Ruilong Huo
> Assignee: Ruilong Huo
> Fix For: 2.0.0
>
>
> Need to improve performance for truncate, especially with small table.
> To be specific, when we get a new oid before truncating table, we try to check if that file already exists on local file system or hdfs by opening it. This can be improved by checking if it exists directly.
> {noformat}
> Oid
> GetNewRelFileNode(Oid reltablespace, bool relisshared, Relation pg_class, bool isAo)
> {
> RelFileNode rnode;
> char *rpath;
> int fd;
> bool collides;
> /* This should match RelationInitPhysicalAddr */
> if (isAo && reltablespace == InvalidOid)
> rnode.spcNode = get_database_dts(MyDatabaseId);
> else if (isAo)
> rnode.spcNode = reltablespace;
> else
> rnode.spcNode = MyDatabaseTableSpace;
> rnode.dbNode = relisshared ? InvalidOid : MyDatabaseId;
> do
> {
> CHECK_FOR_INTERRUPTS();
> /* Generate the OID */
> if (pg_class)
> rnode.relNode = GetNewOid(pg_class);
> else
> rnode.relNode = GetNewObjectId();
> /* Check for existing file of same name */
> rpath = relpath(rnode);
> fd = PathNameOpenFile(rpath, O_RDONLY | PG_BINARY, 0);
> if (fd >= 0)
> {
> /* definite collision */
> gp_retry_close(fd);
> collides = true;
> }
> else
> {
> /*
> * Here we have a little bit of a dilemma: if errno is something
> * other than ENOENT, should we declare a collision and loop? In
> * particular one might think this advisable for, say, EPERM.
> * However there really shouldn't be any unreadable files in a
> * tablespace directory, and if the EPERM is actually complaining
> * that we can't read the directory itself, we'd be in an infinite
> * loop. In practice it seems best to go ahead regardless of the
> * errno. If there is a colliding file we will get an smgr
> * failure when we attempt to create the new relation file.
> */
> collides = false;
> }
> pfree(rpath);
> } while (collides);
> ...
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)