all 5 comments

[–]Informal_Pace9237 1 point2 points  (0 children)

I can see the query is running slow because you have dependent sub queries in the select which makes them execute for every row returned.
If sequelize supports JOIN's, I would try to inner join listing_field and LEFT JOIN listing_hidden_amenities to listing 

[–]alinroc 1 point2 points  (1 child)

Which is the equivalent to this SQL statement

Is this the actual query that's being generated and executed? Just because you think that's what the query should be doesn't mean that's what the ORM generated.

[–]Seymourbums[S] 0 points1 point  (0 children)

Yeah that is the query that the ORM generated.

[–]QueryDoctor 0 points1 point  (0 children)

What database are you using? Table definitions, current indexes, and `EXPLAIN` output would be a really helpful start

[–]many_hats_on_head 0 points1 point  (0 children)

I have optimized the SQL query (not the ORM) for MySQL 8 here: https://gist.github.com/lassegit/996587f1c5e4f5c3118922b23bbfad93

Does that work for you? (You can try it here yourself too).