diff --git a/docs/user/upgrade.rst b/docs/user/upgrade.rst index 7e7815014090..366ed35d92f9 100644 --- a/docs/user/upgrade.rst +++ b/docs/user/upgrade.rst @@ -145,6 +145,7 @@ The following classes have been deprecated and will be removed in a future versi * org.locationtech.geomesa.kafka.confluent.SchemaParser.GeoMesaAvroDeserializableEnumProperty +<<<<<<< HEAD ======= >>>>>>> 16e5072a4a (Add note on NiFi scala version to upgrade guide) <<<<<<< HEAD @@ -184,6 +185,15 @@ The following classes have been deprecated and will be removed in a future versi ======= >>>>>>> d381f46e90 (Add note on NiFi scala version to upgrade guide) >>>>>>> locationtech-main +======= +Partitioned PostGIS Prepared Statements +--------------------------------------- + +If not specified, prepared statements now default to ``true`` in the partitioned PostGIS data store. Prepared +statements are generally faster on insert, and some attribute types (such as list-type attributes) are only +supported through prepared statements. + +>>>>>>> 008807b427 (GEOMESA-3295 Partitioned PostGIS - default to using prepared statements (#2993)) Version 4.0.0 Upgrade Guide +++++++++++++++++++++++++++ diff --git a/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreFactory.scala b/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreFactory.scala index bf40c073c3ec..22c2c99b6c98 100644 --- a/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreFactory.scala +++ b/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreFactory.scala @@ -746,7 +746,7 @@ class PartitionedPostgisDataStoreFactory extends PostgisNGDataStoreFactory with import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgisDialect, PartitionedPostgisPsDialect} >>>>>>> ee1d5f2071 (GEOMESA-3215 Postgis - support List-type attributes) - import PartitionedPostgisDataStoreParams.{DbType, IdleInTransactionTimeout} + import PartitionedPostgisDataStoreParams.{DbType, IdleInTransactionTimeout, PreparedStatements} override def getDisplayName: String = "PostGIS (partitioned)" @@ -756,8 +756,12 @@ import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgis override protected def setupParameters(parameters: java.util.Map[String, AnyRef]): Unit = { super.setupParameters(parameters) +<<<<<<< HEAD <<<<<<< HEAD Seq(DbType, IdleInTransactionTimeout) +======= + Seq(DbType, IdleInTransactionTimeout, PreparedStatements) +>>>>>>> 008807b427 (GEOMESA-3295 Partitioned PostGIS - default to using prepared statements (#2993)) .foreach(p => parameters.put(p.key, p)) } @@ -775,6 +779,7 @@ import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgis source } +<<<<<<< HEAD ======= // override postgis dbkey parameters.put(DbType.key, DbType) @@ -783,6 +788,14 @@ import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgis >>>>>>> 58d14a257e (GEOMESA-3254 Add Bloop build support) override protected def createDataStoreInternal(store: JDBCDataStore, params: java.util.Map[String, _]): JDBCDataStore = { +======= + override protected def createDataStoreInternal(store: JDBCDataStore, baseParams: java.util.Map[String, _]): JDBCDataStore = { + val params = new java.util.HashMap[String, Any](baseParams) + // default to using prepared statements, if not specified + if (!params.containsKey(PreparedStatements.key)) { + params.put(PreparedStatements.key, java.lang.Boolean.TRUE) + } +>>>>>>> 008807b427 (GEOMESA-3295 Partitioned PostGIS - default to using prepared statements (#2993)) val ds = super.createDataStoreInternal(store, params) val dialect = new PartitionedPostgisDialect(ds) diff --git a/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreParams.scala b/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreParams.scala index 515e6b3289de..174d64bdc444 100644 --- a/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreParams.scala +++ b/geomesa-gt/geomesa-gt-partitioning/src/main/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreParams.scala @@ -26,6 +26,15 @@ object PartitionedPostgisDataStoreParams { Collections.singletonMap(Parameter.LEVEL, "program") ) + val PreparedStatements = + new Param( + "preparedStatements", + classOf[java.lang.Boolean], + "Use prepared statements", + false, + java.lang.Boolean.FALSE + ) + val IdleInTransactionTimeout = new Param( "idle_in_transaction_session_timeout", diff --git a/geomesa-gt/geomesa-gt-partitioning/src/test/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreTest.scala b/geomesa-gt/geomesa-gt-partitioning/src/test/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreTest.scala index 186f0fd265fa..82cb692461fc 100644 --- a/geomesa-gt/geomesa-gt-partitioning/src/test/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreTest.scala +++ b/geomesa-gt/geomesa-gt-partitioning/src/test/scala/org/locationtech/geomesa/gt/partition/postgis/PartitionedPostgisDataStoreTest.scala @@ -188,6 +188,7 @@ import org.junit.runner.RunWith import org.locationtech.geomesa.filter.FilterHelper import org.locationtech.geomesa.gt.partition.postgis.dialect.procedures.{DropAgedOffPartitions, PartitionMaintenance, RollWriteAheadLog} import org.locationtech.geomesa.gt.partition.postgis.dialect.tables.UserDataTable +<<<<<<< HEAD import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgisDialect, TableConfig, TypeInfo} ======= import org.geotools.data._ @@ -381,6 +382,9 @@ import org.locationtech.geomesa.gt.partition.postgis.dialect.{TableConfig, TypeI ======= >>>>>>> d18777a94f (GEOMESA-3246 Upgrade Arrow to 11.0.0) >>>>>>> locationtech-main +======= +import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgisDialect, PartitionedPostgisPsDialect, TableConfig, TypeInfo} +>>>>>>> 008807b427 (GEOMESA-3295 Partitioned PostGIS - default to using prepared statements (#2993)) import org.locationtech.geomesa.utils.collection.SelfClosingIterator import org.locationtech.geomesa.utils.geotools.{FeatureUtils, SimpleFeatureTypes} import org.locationtech.geomesa.utils.io.WithClose @@ -3564,6 +3568,29 @@ class PartitionedPostgisDataStoreTest extends Specification with BeforeAfterAll >>>>>>> locationtech-main } + "default to using prepared statements" in { + foreach(Seq(params, params + ("preparedStatements" -> "true"), params - "preparedStatements")) { params => + val ds = DataStoreFinder.getDataStore(params.asJava) + ds must not(beNull) + try { + ds must beAnInstanceOf[JDBCDataStore] + ds.asInstanceOf[JDBCDataStore].getSQLDialect must beAnInstanceOf[PartitionedPostgisPsDialect] + } finally { + ds.dispose() + } + } + foreach(Seq(params + ("preparedStatements" -> "false"))) { params => + val ds = DataStoreFinder.getDataStore(params.asJava) + ds must not(beNull) + try { + ds must beAnInstanceOf[JDBCDataStore] + ds.asInstanceOf[JDBCDataStore].getSQLDialect must beAnInstanceOf[PartitionedPostgisDialect] // not partitioned + } finally { + ds.dispose() + } + } + } + "support idle_in_transaction_session_timeout" in { val sft = SimpleFeatureTypes.renameSft(this.sft, "timeout")