Skip to content
Snippets Groups Projects
user avatar
Moises Lopez authored
The following method:
 - https://github.com/odoo/odoo/blob/2091994c/addons/pos_restaurant/models/pos_config.py#L40

Gets the following query:

    SELECT min("pos_order".id) AS id,
    count("pos_order".id) AS "table_id_count",
    "pos_order"."table_id" as "table_id"
    FROM "pos_order"
    LEFT JOIN "restaurant_table" AS "pos_order__table_id" ON (
        "pos_order"."table_id" = "pos_order__table_id"."id")
    WHERE (("pos_order"."state" = 'draft')
        AND ("pos_order"."table_id" in (TOO MANY IDS HERE)))  -- for this case 178 restaurant_table records ids
    GROUP BY  "pos_order"."table_id", "pos_order__table_id"."id"
    ORDER BY "pos_order__table_id"."id"

It spends 24ms without index

After creating index it spends 0.57

It is not the unique side filtering by pos_order.state column

Check the following lines of code:
 - https://github.com/odoo/odoo/blob/f5553c550/addons/point_of_sale/models/pos_order.py#L678
 - https://github.com/odoo/odoo/blob/f5553c550/addons/point_of_sale/models/pos_order.py#L690
 - https://github.com/odoo/odoo/blob/f5553c550/addons/website_sale_coupon/models/sale_order.py#L91



closes odoo/odoo#129486

Signed-off-by: default avatarRémy Voet (ryv) <ryv@odoo.com>
a658dfcd
History

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials