Skip to content

Commit

Permalink
GEOMESA-3295 Partitioned PostGIS - default to using prepared statemen…
Browse files Browse the repository at this point in the history
  • Loading branch information
a0x8o committed Oct 3, 2023
1 parent 44c281c commit d5f3f28
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/user/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
+++++++++++++++++++++++++++

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand All @@ -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))
}

Expand All @@ -775,6 +779,7 @@ import org.locationtech.geomesa.gt.partition.postgis.dialect.{PartitionedPostgis
source
}

<<<<<<< HEAD
=======
// override postgis dbkey
parameters.put(DbType.key, DbType)
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit d5f3f28

Please sign in to comment.