Skip to content

Commit

Permalink
[ 1828249 ] Query to get data_events for batch creation can get slow
Browse files Browse the repository at this point in the history
This change adds a "batched" boolean field to DataEvent table to indicate whether or not it is part of a batch yet
  • Loading branch information
erilong committed Nov 10, 2007
1 parent 7a70ed2 commit c50b4b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions symmetric/src/main/resources/ddl-config.xml
Expand Up @@ -59,6 +59,7 @@
<column name="data_id" type="INTEGER" required="true" primaryKey="true" />
<column name="node_id" type="VARCHAR" size="50" required="true" primaryKey="true" />
<column name="batch_id" type="INTEGER" />
<column name="batched" type="BOOLEANINT" size="1" required="true" default="0" />
<foreign-key name="fk_de_data_id" foreignTable="data">
<reference local="data_id" foreign="data_id" />
</foreign-key>
Expand All @@ -72,6 +73,10 @@
<index-column name="batch_id" />
<index-column name="node_id" />
</index>
<index name="idx_de_batched_nodeid">
<index-column name="batched" />
<index-column name="node_id" />
</index>
</table>

<table name="node_group">
Expand Down
6 changes: 3 additions & 3 deletions symmetric/src/main/resources/symmetric-services.xml
Expand Up @@ -196,7 +196,7 @@
<property name="selectEventsToBatchSql">
<value>
select data.transaction_id, data.data_id from ${sync.table.prefix}_data data,
${sync.table.prefix}_data_event data_event where data_event.batch_id is null and
${sync.table.prefix}_data_event data_event where data_event.batched = '0' and
data_event.node_id = ? and data.channel_id=? and data.data_id = data_event.data_id
order by data.data_id asc
</value>
Expand All @@ -209,8 +209,8 @@
</property>
<property name="updateBatchedEventsSql">
<value>
update ${sync.table.prefix}_data_event set batch_id = ? where node_id = ? and
data_id = ?
update ${sync.table.prefix}_data_event set batch_id = ?, batched = '1'
where node_id = ? and data_id = ?
</value>
</property>
<property name="selectOutgoingBatchSql">
Expand Down

0 comments on commit c50b4b8

Please sign in to comment.