Sylius/Sylius-Sandbox

Too many SQL queries

Closed this issue · 1 comments

Here is what I got in SQL profiler when visit sandbox app home page:

SET NAMES UTF8
Parameters: { }
Time: 0.16 ms

INSERT INTO sylius_sandbox_cart (locked, total_items, expires_at, value) VALUES (?, ?, ?, ?)
Parameters: { 1: false, 2: 0, 3: Object(DateTime), 4: 0 }
Time: 0.31 ms
SELECT s0_.name AS name0, s0_.slug AS slug1, s0_.position AS position2, s0_.created_at AS created_at3, s0_.updated_at AS updated_at4, s0_.tree_left AS tree_left5, s0_.tree_right AS tree_right6, s0_.tree_level AS tree_level7, s0_.id AS id8, s0_.parent_id AS parent_id9 FROM sylius_sandbox_assortment_category s0_ WHERE s0_.parent_id IS NULL ORDER BY s0_.tree_left ASC
Parameters: { }
Time: 0.16 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [1]
Time: 0.67 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [7]
Time: 0.20 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [8]
Time: 0.17 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [3]
Time: 0.15 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [4]
Time: 0.19 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [5]
Time: 0.22 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [6]
Time: 0.21 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.tree_left AS tree_left6, t0.tree_right AS tree_right7, t0.tree_level AS tree_level8, t0.id AS id9, t0.parent_id AS parent_id10 FROM sylius_sandbox_assortment_category t0 WHERE t0.parent_id = ? ORDER BY t0.tree_left ASC
Parameters: [9]
Time: 0.24 ms

SELECT t0.name AS name1, t0.slug AS slug2, t0.position AS position3, t0.created_at AS created_at4, t0.updated_at AS updated_at5, t0.id AS id6 FROM sylius_sandbox_blogger_category t0
Parameters: { }
Time: 0.18 ms

That is just too many sql queries. If you look at home page, all you have to fetch is shopping cart data, product and blog categories. It should be possible to fetch those with 3 SQL queries, right?

This has been fixed with new CategorizerBundle. Now it takes 1 query.