Closed ghevge closed 1 year ago
BTW I was seeing the same behavior with some older versions too:
My spring DS config looks like this:
spring:
application:
name: test
datasource:
jdbc-url: jdbc:postgresql://mw-db:5432/mw
username: *****
password: *****
idle-timeout: 60000
minimum-idle: 20
connection-timeout: 60000
pool-name: AppPool
initialization-fail-timeout: 30000
login-timeout: 30000
The parametrized query looks like this:
SELECT count(*)
FROM products p
LEFT JOIN products_locations pl ON pl.product_id = p.id AND (pl.latitude <= 45.53563 OR pl.latitude IS NULL) AND (pl.latitude >= 45.4457 OR pl.latitude IS NULL) AND (pl.longitude <= -73.40128 OR pl.longitude IS NULL) AND (pl.longitude >= -73.52957 OR pl.longitude IS NULL)
LEFT JOIN products_descriptions pd ON pd.product_id = p.id AND pd.locale = 'en'
WHERE 1 = 1 AND p.id IN (
(SELECT id FROM products WHERE universal_product_code ILIKE '%tt%' OR model ILIKE '%tt%' OR isbn ILIKE '%tt%')
UNION
(SELECT product_id FROM products_descriptions WHERE (title ILIKE '%tt%' OR description ILIKE '%tt%' OR ts_title @@ websearch_to_tsquery('english'::regconfig, '%tt%') OR ts_description @@ websearch_to_tsquery('english'::regconfig, '%tt%')) AND locale = 'en' )
UNION
(SELECT product_id FROM products_contents WHERE content_id IN (SELECT id FROM contents WHERE (value ILIKE '%tt%' OR ts_value @@ websearch_to_tsquery('english'::regconfig, '%tt%')) AND locale = 'en' ))
UNION
(SELECT product_id FROM products_tags WHERE tag_id IN (SELECT id FROM tags WHERE (value ILIKE '%tt%' OR ts_value @@ websearch_to_tsquery('english'::regconfig, '%tt%')) AND locale = 'en' ))
UNION (SELECT product_id FROM products_labels WHERE label_id IN (SELECT id FROM labels WHERE (value ILIKE '%tt%' OR ts_value @@ websearch_to_tsquery('english'::regconfig, '%tt%')) AND locale = 'en' ))
UNION (SELECT product_id FROM products_brands WHERE brand_id IN (SELECT id FROM brands WHERE (value ILIKE '%tt%' OR ts_value @@ websearch_to_tsquery('english'::regconfig, '%tt%')) AND locale = 'en' ))
UNION (SELECT product_id FROM products_nutrition_facts WHERE id IN (SELECT product_nutrition_fact_id FROM products_nutrition_facts_names WHERE nutrient_name_id IN (SELECT id FROM nutrients_names WHERE (value ILIKE '%tt%' OR ts_value @@ websearch_to_tsquery('english'::regconfig, '%tt%')) AND locale = 'en' ))) )
When I run a complex SELECT count(*) query on a postgresql DB from my spring boot mybatis application, the query hangs, and never returns.
If I run the same query against the same DB, but using DBeaver functionality, the query returns in ~ 300 milliseconds. So it doesn't seem to be something wrong with the DB.
My app is a Java 17, spring boot postgresql application with the following versions:
The logs that my app are generating when sending this query are:
The transaction status on postgresql side looks like this:
My postgresql docker definition looks like this:
I just added polish full text support on top of pgroonga container.
I have about 25k unique products entries in my products DB
Any idea what might be causing mybatis to hang on these request ?
Thanks