From: Paul Ramsey Date: Wed, 22 Jul 2015 16:14:54 +0000 (+0000) Subject: #2562, ANALYZE tables after shp2pgsql load X-Git-Tag: 2.2.0rc1~226 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef5c3e4b69afea1d088312d869acf8e1d119635d;p=postgis #2562, ANALYZE tables after shp2pgsql load git-svn-id: http://svn.osgeo.org/postgis/trunk@13832 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index 47f5202c9..44e08c7a1 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -1958,6 +1958,14 @@ ShpLoaderGetSQLFooter(SHPLOADERSTATE *state, char **strfooter) stringbuffer_aprintf(sb, "COMMIT;\n"); } + /* Always ANALYZE the resulting table, for better stats */ + stringbuffer_aprintf(sb, "ANALYZE "); + if (state->config->schema) + { + stringbuffer_aprintf(sb, "\"%s\".", state->config->schema); + } + stringbuffer_aprintf(sb, "\"%s\";\n", state->config->table); + /* Copy the string buffer into a new string, destroying the string buffer */ ret = (char *)malloc(strlen((char *)stringbuffer_getstring(sb)) + 1); strcpy(ret, (char *)stringbuffer_getstring(sb));