Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use Query hint #125

Open
ddaeyongee opened this issue May 18, 2022 · 2 comments
Open

how to use Query hint #125

ddaeyongee opened this issue May 18, 2022 · 2 comments
Assignees

Comments

@ddaeyongee
Copy link

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 cer self-assigned this May 25, 2022
@cer
Copy link
Contributor

cer commented May 25, 2022

These SQL statements are hardwired into PollingDao:

String findEventsQuery = eventuateSqlDialect.addLimitToSql(String.format("SELECT * FROM %s WHERE %s = 0 ORDER BY %s ASC",
handler.getQualifiedTable(), PUBLISHED_FIELD, pk), ":limit");

and

String markEventsAsReadQuery = String.format("UPDATE %s SET %s = 1 WHERE %s in (:ids)",
handler.getQualifiedTable(), PUBLISHED_FIELD, pk);

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

@ddaeyongee Thoughts?

@ddaeyongee
Copy link
Author

ddaeyongee commented Jun 13, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants