src/hg/lib/joiner.c 1.28
1.28 2009/02/11 18:49:44 angie
Performance fix for tableExists: use sqlTableWildExists only when table name has a wildcard, because in large dbs like hg18, sqlTableWildExists is ~100x slower than sqlTableExists (0.090s --> 0.000s). When joining through gbCdnaInfo, we may call tableExists 255 times to find a path to tissue.name.
Index: src/hg/lib/joiner.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/joiner.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -b -B -U 4 -r1.27 -r1.28
--- src/hg/lib/joiner.c 17 Sep 2008 18:10:13 -0000 1.27
+++ src/hg/lib/joiner.c 11 Feb 2009 18:49:44 -0000 1.28
@@ -1075,20 +1075,21 @@
* check for existence with and without it. */
{
struct sqlConnection *conn = sqlMayConnect(database);
boolean exists;
+boolean hasSqlWildcard = (strchr(table, '%') || strchr(table, '_'));
char t2[1024];
if (conn == NULL)
return FALSE;
if (isNotEmpty(splitPrefix))
safef(t2, sizeof(t2), "%s%s", splitPrefix, table);
else
safef(t2, sizeof(t2), "%s", table);
-exists = sqlTableWildExists(conn, t2);
+exists = hasSqlWildcard ? sqlTableWildExists(conn, t2) : sqlTableExists(conn, t2);
if (!exists && isNotEmpty(splitPrefix))
{
safef(t2, sizeof(t2), "%s", table);
- exists = sqlTableExists(conn, t2);
+ exists = hasSqlWildcard ? sqlTableWildExists(conn, t2) : sqlTableExists(conn, t2);
}
sqlDisconnect(&conn);
return exists;
}