eventuate-foundation / eventuate-cdc

Other
73 stars 31 forks source link

how to use Query hint #125

Open ddaeyongee opened 2 years ago

ddaeyongee commented 2 years ago

hi. I'm Taeyong. I have one question. I would like to add a query hint to improve performance when processing large volumes.

path : eventuate-local-java-cdc-connector-polling/src/main/java/io/eventuate/local/polling/PollingDao.java existing query String markEventsAsReadQuery = String.format("UPDATE %s SET %s = 1 WHERE %s in (:ids)", handler.getQualifiedTable(), PUBLISHED_FIELD, pk);

Query hint to add : String markEventsAsReadQuery = String.format("UPDATE ### /+ index_rs(handler.getQualifiedTable()) / %s SET %s = 1 WHERE %s in (:ids)", handler.getQualifiedTable(), PUBLISHED_FIELD, pk);

Or is there another way without directly modifying the query in 'String.format'

thank you !

cer commented 2 years ago

These SQL statements are hardwired into PollingDao:

https://github.com/eventuate-foundation/eventuate-cdc/blob/eba1d54ae37dc44a4cb58479abab9fd268dbe899/eventuate-local-java-cdc-connector-polling/src/main/java/io/eventuate/local/polling/PollingDao.java#L119-L120

and

https://github.com/eventuate-foundation/eventuate-cdc/blob/eba1d54ae37dc44a4cb58479abab9fd268dbe899/eventuate-local-java-cdc-connector-polling/src/main/java/io/eventuate/local/polling/PollingDao.java#L150-L151

One simple solution would be to make these SQL statements configurable via properties:

@ddaeyongee Thoughts?

ddaeyongee commented 2 years ago

@cer thanks your comment. I have accepted your comment. And I changed the oracle query hint to a String string as shown below and reflected it to the CDC server through gradle service.build .

[file path] eventuate-local-java-cdc-connector-polling/src/main/java/io/eventuate/local/polling/PollingDao.java

[as-is] 150line ... String markEventsAsReadQuery = String.format("UPDATE %s SET %s = 1 WHERE %s in (:ids)", handler.getQualifiedTable(), PUBLISHED_FIELD, pk); ...

[fixed] ... String markEventsAsReadQuery = String.format("UPDATE %s /+ index_rs(%s) / SET %s = 1 WHERE %s in (:ids)", handler.getQualifiedTable(), PUBLISHED_FIELD, pk); ...

and One more question, please check if it is possible to add OracleDialect to "package io.eventuate.sql.dialect". For microservices currently using oracle RDBMS, I create and use it myself.

I always appreciate your active support.