-
Notifications
You must be signed in to change notification settings - Fork 2
faster sql query, fixes #15 #17
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17 +/- ##
============================================
+ Coverage 41.17% 42.28% +1.10%
+ Complexity 52 51 -1
============================================
Files 12 12
Lines 153 149 -4
============================================
Hits 63 63
+ Misses 90 86 -4 ☔ View full report in Codecov by Sentry. |
Thanks, indeed it fixes the issue but we want to ensure just a little bit more; this query will return success even if the database in question does not exist or is compleltely empty, while we want to do the basic sanity check that things "work". So I think we'll only merge this if indeed the query in question is in fact configurable. |
Is there a way to disable this test then from the application? It's broken
for Postgres databases, so I can't use it at all.
Or just get rid of the backticks? Or...?
…On Thu, Apr 4, 2024 at 12:53 AM Thijs Kinkhorst ***@***.***> wrote:
Thanks, indeed it fixes the issue but we want to ensure just a little bit
more; this query will return success even if the database in question does
not exist or is compleltely empty, while we want to do the basic sanity
check that things "work". So I think we'll only merge this if indeed the
query in question is in fact configurable.
—
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEXIQKQ6M63TL2NK4YBX3TY3TMDJAVCNFSM6AAAAABFVSDIN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZWGE4DQMJSGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
You could also split the services, select 1 is fast and ensure that there's
a database server, and a custom one, which checks the table, etc.
But is there even a way to disable services from the application now?
…On Thu, Apr 4, 2024 at 7:06 AM Tac Tacelosky ***@***.***> wrote:
Is there a way to disable this test then from the application? It's broken
for Postgres databases, so I can't use it at all.
Or just get rid of the backticks? Or...?
On Thu, Apr 4, 2024 at 12:53 AM Thijs Kinkhorst ***@***.***>
wrote:
> Thanks, indeed it fixes the issue but we want to ensure just a little bit
> more; this query will return success even if the database in question does
> not exist or is compleltely empty, while we want to do the basic sanity
> check that things "work". So I think we'll only merge this if indeed the
> query in question is in fact configurable.
>
> —
> Reply to this email directly, view it on GitHub
> <#17 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAEXIQKQ6M63TL2NK4YBX3TY3TMDJAVCNFSM6AAAAABFVSDIN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZWGE4DQMJSGA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
@tacman if the current query is not working correctly on other database platforms then by all means, feel free to suggest a better query that runs on more platforms. If the backticks are the only thing messing things up, feel free to remove them here. I do like your suggestion, to inject the query from the config. That way a user can configure an appropriate query for the application the monitor bundle is running on. Some thoughts:
If you mean: is it possible to remove a service from being added to the health checker service? My answer is yes and no. Any service that is tagged with the Monitor-bundle/src/DependencyInjection/Compiler/HealthCheckPass.php Lines 44 to 46 in 9fad7f1
No: that config is now hard coded in the services.yaml file. So it would need some tweaking to make it configurable. Hope this helps you somewhat. If you need some more help, feel free to reach out to me on the OpenConext Slack channel or on the Symfony Devs Slack. You should be able to find me there |
How about instead of hand-coding the query:
We use a querybuilder, which automatically escapes the table name. $this->entityManager->createQueryBuilder()
->from($table->getName())
->setMaxResults(1)
->getQuery()
->getResult(); // or a count query, getOneOrNull(), or whatever. There are faster ways to do this, but I think this will at least allow postgres. Maybe use the queryCache, since we're not actually concerned with the data? Or even a limit of 0, which would make the query but not hydrate an entity, though maybe you want to test that. |
I think the backticks are only relevant when the table name is a reserved work. Unfortunately, Symfony's 'make:user' command create a |
I'd love to use the bundle, but because I use postgres it consistently fails. I know the select 1 didn't accomplish what you want, but I'm not sure how to fix this. |
We think that should work for us as well. The performance penalty should be minimal. So feel free to go ahead with this suggestion. |
Hi @tacman. Can you move forward with the suggested change? An alternative that we would find acceptable to make the full SQL query a configurable string in the bundle config. That also seems like a flexible and generic solution. |
ok, to confirm, that's
I think getOneOrNull is good, because it has the benefit of hydrating the entity, so it will throw an error if a migration (on that table) is missing. |
No description provided.