@@ -323,34 +323,14 @@ void table_connection_t::stop(pg_conn_t const &db_connection, bool updateable,
323323 flex_table_t ::table_type::permanent, table ().full_tmp_name ()));
324324
325325 std::string const columns = table ().build_sql_column_list ();
326- std::string sql = fmt::format (" INSERT INTO {} ({}) SELECT {} FROM {}" ,
327- table ().full_tmp_name (), columns, columns,
328- table ().full_name ());
329-
330- auto const postgis_version = get_postgis_version ();
331326
332327 auto const geom_column_name =
333328 " \" " + table ().geom_column ().name () + " \" " ;
334329
335- sql += " ORDER BY " ;
336- if (postgis_version.major == 2 && postgis_version.minor < 4 ) {
337- log_debug (" Using GeoHash for clustering table '{}'" ,
338- table ().name ());
339- if (table ().geom_column ().srid () == 4326 ) {
340- sql += fmt::format (" ST_GeoHash({},10)" , geom_column_name);
341- } else {
342- sql += fmt::format (
343- " ST_GeoHash(ST_Transform(ST_Envelope({}),4326),10)" ,
344- geom_column_name);
345- }
346- sql += " COLLATE \" C\" " ;
347- } else {
348- log_debug (" Using native order for clustering table '{}'" ,
349- table ().name ());
350- // Since Postgis 2.4 the order function for geometries gives
351- // useful results.
352- sql += geom_column_name;
353- }
330+ std::string const sql =
331+ fmt::format (" INSERT INTO {} ({}) SELECT {} FROM {} ORDER BY {}" ,
332+ table ().full_tmp_name (), columns, columns,
333+ table ().full_name (), geom_column_name);
354334
355335 db_connection.exec (sql);
356336
0 commit comments