[
https://issues.apache.org/jira/browse/SCB-829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16575668#comment-16575668
]
ASF GitHub Bot commented on SCB-829:
------------------------------------
WillemJiang closed pull request #246: SCB-829 An index on TxEvent (globalTxId)
should be added
URL: https://github.com/apache/incubator-servicecomb-saga/pull/246
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/alpha/alpha-server/src/main/resources/schema-mysql.sql
b/alpha/alpha-server/src/main/resources/schema-mysql.sql
index b1598573..85522a7a 100644
--- a/alpha/alpha-server/src/main/resources/schema-mysql.sql
+++ b/alpha/alpha-server/src/main/resources/schema-mysql.sql
@@ -30,7 +30,8 @@ CREATE TABLE IF NOT EXISTS TxEvent (
retries int(11) NOT NULL DEFAULT '0',
retryMethod varchar(256) DEFAULT NULL,
PRIMARY KEY (surrogateId),
- INDEX saga_events_index (surrogateId, globalTxId, localTxId, type,
expiryTime)
+ INDEX saga_events_index (surrogateId, globalTxId, localTxId, type,
expiryTime),
+ INDEX saga_global_tx_index (globalTxId)
) DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS Command (
diff --git a/alpha/alpha-server/src/main/resources/schema-postgresql.sql
b/alpha/alpha-server/src/main/resources/schema-postgresql.sql
index b3f77023..bf8244b4 100644
--- a/alpha/alpha-server/src/main/resources/schema-postgresql.sql
+++ b/alpha/alpha-server/src/main/resources/schema-postgresql.sql
@@ -32,6 +32,7 @@ CREATE TABLE IF NOT EXISTS TxEvent (
);
CREATE INDEX IF NOT EXISTS saga_events_index ON TxEvent (surrogateId,
globalTxId, localTxId, type, expiryTime);
+CREATE INDEX IF NOT EXISTS saga_global_tx_index ON TxEvent (globalTxId);
CREATE TABLE IF NOT EXISTS Command (
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> An index on TxEvent (globalTxId) should be added
> ------------------------------------------------
>
> Key: SCB-829
> URL: https://issues.apache.org/jira/browse/SCB-829
> Project: Apache ServiceComb
> Issue Type: Improvement
> Components: Saga
> Affects Versions: saga-0.3.0
> Environment: postgres and mysql
> Reporter: FuChenGeng
> Priority: Minor
> Labels: easyfix
> Fix For: saga-0.3.0
>
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> When the amount of data in the TxEvent table is large, the select SQL
> statement of method(
> findByEventGlobalTxIdAndEventType
> ) is executed very slowly. Here, an index on globalTxId should be added.
>
> Here is the SQL statement. it will be executed 3 times in a transaction with
> 2 subtransactions.
> @Query("SELECT DISTINCT new org.apache.servicecomb.saga.alpha.core.TxEvent("
> + "t.serviceName, t.instanceId, t.globalTxId, t.localTxId, t.parentTxId, "
> + "t.type, t.compensationMethod, t.payloads "
> + ") FROM TxEvent t "
> + "WHERE t.globalTxId = ?1 AND t.type = ?2 "
> + " AND ( SELECT MIN(t1.retries) FROM TxEvent t1 "
> + " WHERE t1.globalTxId = t.globalTxId "
> + " AND t1.localTxId = t.localTxId "
> + " AND t1.type IN ('TxStartedEvent', 'SagaStartedEvent') ) = 0 ")
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)