3

I am currently experiencing very long sync times on a zumero synced database (well over a minute), and following some profiling, the culprit appears to be a particular query that is taking 20+ seconds (suitably anonymised):

WITH relevant_rvs AS
(
  SELECT rv.z_rv AS rv FROM zumero."mydb_089eb7ec0e2e4772ba0dde90170ee368_mysynceddb$z$rv$271340031" rv
  WHERE (rv.txid<=913960)
  AND NOT EXISTS (SELECT 1 FROM zumero."mydb_089eb7ec0e2e4772ba0dde90170ee368_mysynceddb$z$dd$271340031" dd WHERE dd.rv=rv.z_rv AND (dd.txid<=913960))
)
INSERT INTO #final_included_271340031_e021cfbe1c97213dd5adbacd667c08439fb8c6 (z_rv)
SELECT z$this.z_rv
 FROM zumero."mydb_089eb7ec0e2e4772ba0dde90170ee368_mysynceddb$z$271340031" z$this
  WHERE (z$this.z_rv IN (SELECT rv FROM relevant_rvs))
  AND MyID = (MyID = XXX AND MyOtherField=XXX)
UNION SELECT z$this.z_rv
 FROM zumero."mydb_089eb7ec0e2e4772ba0dde90170ee368_mysynceddb$z$old$271340031" z$this
  WHERE (z$this.z_rv IN (SELECT rv FROM relevant_rvs))
  AND (MyID = XXX AND MyOtherField=XXX)

I have taken the latter SELECT part of the query and ran it in isolation, which reproduces the same poor performance. Interestingly the execution plan recommends an index be applied, but I'm reluctant to go changing the schema of zumero generated tables, is adding indexes to these tables something that can be attempted safely and is it likely to help?

The source tables have 100,000ish records in them and the filter results in each client syncing 100-1000ish records, so not trivial data volumes but levels I would not expect to be causing major issues in terms of query performance.

Does anyone have any experience optimising Zumero sync performance server side? Do any indexes on source tables propagate to these tables? they don't appear to in this case.

4

1 回答 1

4

在表上创建自定义索引z$old应该是安全的。我希望它有助于提高您的查询性能!(很高兴看到评论告诉我们是否这样做。)

我相信这样的索引可能导致的唯一问题是它可能会阻止主机表上的某些模式更改。例如,如果您尝试[MyOtherField]从主机表中删除列,Zumero 触发器也会尝试从z$old表中删除同一列,并且事务将失败并出现错误(这可能有点令人惊讶,因为索引不在直接作用的桌子上)。

另一件需要考虑的事情:如果它出现在错误消息中,给这个新索引起一个可以被识别/有用的名称也可能会有所帮助。然后(一如既往)随时联系 support@zumero.com 如有任何进一步的问题或问题。

于 2015-09-24T15:36:44.103 回答