/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/sql/sql-8821-011/main.sql
42 строки
1 KB
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
-- Сравнение производительности с подсказкой и без нее -- Тест 1: Без подсказки SET STATISTICS TIME ON; SET STATISTICS IO ON; SELECT c.customer_name, p.product_category, SUM(oi.quantity) AS total_quantity, SUM(oi.quantity * oi.unit_price) AS total_amount FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY c.customer_name, p.product_category HAVING SUM(oi.quantity * oi.unit_price) > 10000 ORDER BY total_amount DESC; SET STATISTICS TIME OFF; SET STATISTICS IO OFF; -- Тест 2: С подсказкой SET STATISTICS TIME ON; SET STATISTICS IO ON; SELECT /*+ USE_HASH(c o oi p) PARALLEL(4) */ c.customer_name, p.product_category, SUM(oi.quantity) AS total_quantity, SUM(oi.quantity * oi.unit_price) AS total_amount FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY c.customer_name, p.product_category HAVING SUM(oi.quantity * oi.unit_price) > 10000 ORDER BY total_amount DESC; SET STATISTICS TIME OFF; SET STATISTICS IO OFF;