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

nodejs v18.17.1 / v20.9.0 - pg ^8.11.0 - slow select query #3098

Open
Dimitris-Tzilopoylos opened this issue Nov 12, 2023 · 2 comments
Open

Comments

@Dimitris-Tzilopoylos
Copy link

I am using the following query to retrieve users from database, and before this one i just perform a count(*) to retrieve the total number of users.

SELECT coalesce(json_agg(_0_users),'[]') as users 
        FROM (
          SELECT row_to_json((
            SELECT _0_users
            FROM ( SELECT _0_users.id,_0_users.email,_0_users.password,_0_users.name,_0_users.last_name,_0_users.created_at,_0_users.verified,_0_users.blacklist,_0_users.profile_image,_0_users.role_id,_0_users.country_id,_0_users.city,_0_users.phone,_0_users.address,_0_users.postal_code,_0_users.is_business,_0_users.business_name,_0_users.business_address,_0_users.business_country_id,_0_users.vat,_0_users.parent_id) _0_users )) _0_users
            FROM (
              SELECT  _0_users.id,_0_users.email,_0_users.password,_0_users.name,_0_users.last_name,_0_users.created_at,_0_users.verified,_0_users.blacklist,_0_users.profile_image,_0_users.role_id,_0_users.country_id,_0_users.city,_0_users.phone,_0_users.address,_0_users.postal_code,_0_users.is_business,_0_users.business_name,_0_users.business_address,_0_users.business_country_id,_0_users.vat,_0_users.parent_id FROM public.users _0_users
       ) _0_users
       ) _0_users

The execution with nodejs v18.17.1 / v20.9.0 - pg ^8.11.0 results to something between 60 and 92 ms for both count and the query mentioned above, but the same process with nodejs v16.20.2 results to 12ms for both queries (average).
Are there any issues with node-postgres and nodejs versions > 16? Am I missing something?

@Dimitris-Tzilopoylos
Copy link
Author

Cannot reproduce it on different machines,except windows 11 for unknown reasons

@brianc
Copy link
Owner

brianc commented Nov 13, 2023

Very strange! Sounds like more of an issue w/ something internal to node on v18/20 on windows. Please lmk if you track down what it is!

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

No branches or pull requests

2 participants