
Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
|
24.07.2013, 20:14:57
|
|||
|---|---|---|---|
|
|||
Не хочет использовать индексы в простом запросе |
|||
|
#18+
Добрый день. Проблема в том что MySQL не хочет использовать индексы в запросе. Подскажите в чем дело или что почитать, запрос вроди бы простой... Пытался уже и limit ставить и null убирать, ранее по умолчанию для поля был null. Вобщим помогите пожалуйста уважаемые коллеги. Запрос: SELECT `sales_flat_order`.* FROM `sales_flat_order` WHERE (sales_flat_order.increment_id=100358224); Выполняется времени: 1 row in set (2.62 sec) Описание запроса: EXPLAIN EXTENDED SELECT `sales_flat_order`.* FROM `sales_flat_order` WHERE (sales_flat_order.increment_id=100358224); +----+-------------+--------------------+-------+---------------------------+------+----------+-------+----------+----------+-----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+--------------------+-------+---------------------------+------+----------+-------+----------+----------+-----------------+ | 1 | SIMPLE | sales_flat_order | ALL | UNQ_INCREMENT_ID | NULL | NULL | NULL | 379518 | 100.00 | Using where | +----+-------------+--------------------+-------+---------------------------+------+----------+-------+----------+----------+-----------------+ Записей в таблице: 366104 Из desc sales_flat_order: +------------------------------------------+----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------------------------------+----------------------+------+-----+---------+----------------+ | increment_id | varchar(50) | YES | UNI | NULL | | +------------------------------------------+----------------------+------+-----+---------+----------------+ Таблица: CREATE TABLE `sales_flat_order` ( `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `state` varchar(32) DEFAULT NULL, `status` varchar(32) DEFAULT NULL, `coupon_code` varchar(255) DEFAULT NULL, `protect_code` varchar(255) DEFAULT NULL, `shipping_description` varchar(255) DEFAULT NULL, `is_virtual` tinyint(1) unsigned DEFAULT NULL, `store_id` smallint(5) unsigned DEFAULT NULL, `customer_id` int(10) unsigned DEFAULT NULL, `base_discount_amount` decimal(12,4) DEFAULT NULL, `base_discount_canceled` decimal(12,4) DEFAULT NULL, `base_discount_invoiced` decimal(12,4) DEFAULT NULL, `base_discount_refunded` decimal(12,4) DEFAULT NULL, `base_grand_total` decimal(12,4) DEFAULT NULL, `base_shipping_amount` decimal(12,4) DEFAULT NULL, `base_shipping_canceled` decimal(12,4) DEFAULT NULL, `base_shipping_invoiced` decimal(12,4) DEFAULT NULL, `base_shipping_refunded` decimal(12,4) DEFAULT NULL, `base_shipping_tax_amount` decimal(12,4) DEFAULT NULL, `base_shipping_tax_refunded` decimal(12,4) DEFAULT NULL, `base_subtotal` decimal(12,4) DEFAULT NULL, `base_subtotal_canceled` decimal(12,4) DEFAULT NULL, `base_subtotal_invoiced` decimal(12,4) DEFAULT NULL, `base_subtotal_refunded` decimal(12,4) DEFAULT NULL, `base_tax_amount` decimal(12,4) DEFAULT NULL, `base_tax_canceled` decimal(12,4) DEFAULT NULL, `base_tax_invoiced` decimal(12,4) DEFAULT NULL, `base_tax_refunded` decimal(12,4) DEFAULT NULL, `base_to_global_rate` decimal(12,4) DEFAULT NULL, `base_to_order_rate` decimal(12,4) DEFAULT NULL, `base_total_canceled` decimal(12,4) DEFAULT NULL, `base_total_invoiced` decimal(12,4) DEFAULT NULL, `base_total_invoiced_cost` decimal(12,4) DEFAULT NULL, `base_total_offline_refunded` decimal(12,4) DEFAULT NULL, `base_total_online_refunded` decimal(12,4) DEFAULT NULL, `base_total_paid` decimal(12,4) DEFAULT NULL, `base_total_qty_ordered` decimal(12,4) DEFAULT NULL, `base_total_refunded` decimal(12,4) DEFAULT NULL, `discount_amount` decimal(12,4) DEFAULT NULL, `discount_canceled` decimal(12,4) DEFAULT NULL, `discount_invoiced` decimal(12,4) DEFAULT NULL, `discount_refunded` decimal(12,4) DEFAULT NULL, `grand_total` decimal(12,4) DEFAULT NULL, `shipping_amount` decimal(12,4) DEFAULT NULL, `shipping_canceled` decimal(12,4) DEFAULT NULL, `shipping_invoiced` decimal(12,4) DEFAULT NULL, `shipping_refunded` decimal(12,4) DEFAULT NULL, `shipping_tax_amount` decimal(12,4) DEFAULT NULL, `shipping_tax_refunded` decimal(12,4) DEFAULT NULL, `store_to_base_rate` decimal(12,4) DEFAULT NULL, `store_to_order_rate` decimal(12,4) DEFAULT NULL, `subtotal` decimal(12,4) DEFAULT NULL, `subtotal_canceled` decimal(12,4) DEFAULT NULL, `subtotal_invoiced` decimal(12,4) DEFAULT NULL, `subtotal_refunded` decimal(12,4) DEFAULT NULL, `tax_amount` decimal(12,4) DEFAULT NULL, `tax_canceled` decimal(12,4) DEFAULT NULL, `tax_invoiced` decimal(12,4) DEFAULT NULL, `tax_refunded` decimal(12,4) DEFAULT NULL, `total_canceled` decimal(12,4) DEFAULT NULL, `total_invoiced` decimal(12,4) DEFAULT NULL, `total_offline_refunded` decimal(12,4) DEFAULT NULL, `total_online_refunded` decimal(12,4) DEFAULT NULL, `total_paid` decimal(12,4) DEFAULT NULL, `total_qty_ordered` decimal(12,4) DEFAULT NULL, `total_refunded` decimal(12,4) DEFAULT NULL, `can_ship_partially` tinyint(1) unsigned DEFAULT NULL, `can_ship_partially_item` tinyint(1) unsigned DEFAULT NULL, `customer_is_guest` tinyint(1) unsigned DEFAULT NULL, `customer_note_notify` tinyint(1) unsigned DEFAULT NULL, `billing_address_id` int(10) DEFAULT NULL, `customer_group_id` smallint(5) DEFAULT NULL, `edit_increment` int(10) DEFAULT NULL, `email_sent` tinyint(1) unsigned DEFAULT NULL, `forced_do_shipment_with_invoice` tinyint(1) unsigned DEFAULT NULL, `gift_message_id` int(10) DEFAULT NULL, `payment_authorization_expiration` int(10) DEFAULT NULL, `paypal_ipn_customer_notified` int(10) DEFAULT NULL, `quote_address_id` int(10) DEFAULT NULL, `quote_id` int(10) DEFAULT NULL, `shipping_address_id` int(10) DEFAULT NULL, `adjustment_negative` decimal(12,4) DEFAULT NULL, `adjustment_positive` decimal(12,4) DEFAULT NULL, `base_adjustment_negative` decimal(12,4) DEFAULT NULL, `base_adjustment_positive` decimal(12,4) DEFAULT NULL, `base_shipping_discount_amount` decimal(12,4) DEFAULT NULL, `base_subtotal_incl_tax` decimal(12,4) DEFAULT NULL, `base_total_due` decimal(12,4) DEFAULT NULL, `payment_authorization_amount` decimal(12,4) DEFAULT NULL, `shipping_discount_amount` decimal(12,4) DEFAULT NULL, `subtotal_incl_tax` decimal(12,4) DEFAULT NULL, `total_due` decimal(12,4) DEFAULT NULL, `weight` decimal(12,4) DEFAULT NULL, `customer_dob` datetime DEFAULT NULL, `increment_id` varchar(50) DEFAULT NULL, `applied_rule_ids` varchar(255) DEFAULT NULL, `base_currency_code` char(3) DEFAULT NULL, `customer_email` varchar(255) DEFAULT NULL, `customer_firstname` varchar(255) DEFAULT NULL, `customer_lastname` varchar(255) DEFAULT NULL, `customer_middlename` varchar(255) DEFAULT NULL, `customer_prefix` varchar(255) DEFAULT NULL, `customer_suffix` varchar(255) DEFAULT NULL, `customer_taxvat` varchar(255) DEFAULT NULL, `discount_description` varchar(255) DEFAULT NULL, `ext_customer_id` varchar(255) DEFAULT NULL, `ext_order_id` varchar(255) DEFAULT NULL, `global_currency_code` char(3) DEFAULT NULL, `hold_before_state` varchar(255) DEFAULT NULL, `hold_before_status` varchar(255) DEFAULT NULL, `order_currency_code` varchar(255) DEFAULT NULL, `original_increment_id` varchar(50) DEFAULT NULL, `relation_child_id` varchar(32) DEFAULT NULL, `relation_child_real_id` varchar(32) DEFAULT NULL, `relation_parent_id` varchar(32) DEFAULT NULL, `relation_parent_real_id` varchar(32) DEFAULT NULL, `remote_ip` varchar(255) DEFAULT NULL, `shipping_method` varchar(255) DEFAULT NULL, `store_currency_code` char(3) DEFAULT NULL, `store_name` varchar(255) DEFAULT NULL, `x_forwarded_for` varchar(255) DEFAULT NULL, `customer_note` text, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `total_item_count` smallint(5) unsigned DEFAULT '0', `customer_gender` int(11) DEFAULT NULL, `hidden_tax_amount` decimal(12,4) DEFAULT NULL, `base_hidden_tax_amount` decimal(12,4) DEFAULT NULL, `shipping_hidden_tax_amount` decimal(12,4) DEFAULT NULL, `base_shipping_hidden_tax_amount` decimal(12,4) DEFAULT NULL, `hidden_tax_invoiced` decimal(12,4) DEFAULT NULL, `base_hidden_tax_invoiced` decimal(12,4) DEFAULT NULL, `hidden_tax_refunded` decimal(12,4) DEFAULT NULL, `base_hidden_tax_refunded` decimal(12,4) DEFAULT NULL, `shipping_incl_tax` decimal(12,4) DEFAULT NULL, `base_shipping_incl_tax` decimal(12,4) DEFAULT NULL, `base_customer_balance_amount` decimal(12,4) DEFAULT NULL, `customer_balance_amount` decimal(12,4) DEFAULT NULL, `base_customer_balance_invoiced` decimal(12,4) DEFAULT NULL, `customer_balance_invoiced` decimal(12,4) DEFAULT NULL, `base_customer_balance_refunded` decimal(12,4) DEFAULT NULL, `customer_balance_refunded` decimal(12,4) DEFAULT NULL, `base_customer_balance_total_refunded` decimal(12,4) DEFAULT NULL, `customer_balance_total_refunded` decimal(12,4) DEFAULT NULL, `gift_cards` text, `base_gift_cards_amount` decimal(12,4) DEFAULT NULL, `gift_cards_amount` decimal(12,4) DEFAULT NULL, `base_gift_cards_invoiced` decimal(12,4) DEFAULT NULL, `gift_cards_invoiced` decimal(12,4) DEFAULT NULL, `base_gift_cards_refunded` decimal(12,4) DEFAULT NULL, `gift_cards_refunded` decimal(12,4) DEFAULT NULL, `gw_id` int(10) unsigned DEFAULT NULL, `gw_allow_gift_receipt` int(10) unsigned DEFAULT NULL, `gw_add_printed_card` int(10) unsigned DEFAULT NULL, `gw_base_price` decimal(12,4) DEFAULT NULL, `gw_price` decimal(12,4) DEFAULT NULL, `gw_items_base_price` decimal(12,4) DEFAULT NULL, `gw_items_price` decimal(12,4) DEFAULT NULL, `gw_printed_card_base_price` decimal(12,4) DEFAULT NULL, `gw_printed_card_price` decimal(12,4) DEFAULT NULL, `gw_base_tax_amount` decimal(12,4) DEFAULT NULL, `gw_tax_amount` decimal(12,4) DEFAULT NULL, `gw_items_base_tax_amount` decimal(12,4) DEFAULT NULL, `gw_items_tax_amount` decimal(12,4) DEFAULT NULL, `gw_printed_card_base_tax_amount` decimal(12,4) DEFAULT NULL, `gw_printed_card_tax_amount` decimal(12,4) DEFAULT NULL, `gw_base_price_invoiced` decimal(12,4) DEFAULT NULL, `gw_price_invoiced` decimal(12,4) DEFAULT NULL, `gw_items_base_price_invoiced` decimal(12,4) DEFAULT NULL, `gw_items_price_invoiced` decimal(12,4) DEFAULT NULL, `gw_printed_card_base_price_invoiced` decimal(12,4) DEFAULT NULL, `gw_printed_card_price_invoiced` decimal(12,4) DEFAULT NULL, `gw_base_tax_amount_invoiced` decimal(12,4) DEFAULT NULL, `gw_tax_amount_invoiced` decimal(12,4) DEFAULT NULL, `gw_items_base_tax_amount_invoiced` decimal(12,4) DEFAULT NULL, `gw_items_tax_amount_invoiced` decimal(12,4) DEFAULT NULL, `gw_printed_card_base_tax_amount_invoiced` decimal(12,4) DEFAULT NULL, `gw_printed_card_tax_amount_invoiced` decimal(12,4) DEFAULT NULL, `gw_base_price_refunded` decimal(12,4) DEFAULT NULL, `gw_price_refunded` decimal(12,4) DEFAULT NULL, `gw_items_base_price_refunded` decimal(12,4) DEFAULT NULL, `gw_items_price_refunded` decimal(12,4) DEFAULT NULL, `gw_printed_card_base_price_refunded` decimal(12,4) DEFAULT NULL, `gw_printed_card_price_refunded` decimal(12,4) DEFAULT NULL, `gw_base_tax_amount_refunded` decimal(12,4) DEFAULT NULL, `gw_tax_amount_refunded` decimal(12,4) DEFAULT NULL, `gw_items_base_tax_amount_refunded` decimal(12,4) DEFAULT NULL, `gw_items_tax_amount_refunded` decimal(12,4) DEFAULT NULL, `gw_printed_card_base_tax_amount_refunded` decimal(12,4) DEFAULT NULL, `gw_printed_card_tax_amount_refunded` decimal(12,4) DEFAULT NULL, `reward_points_balance` int(10) unsigned DEFAULT NULL, `base_reward_currency_amount` decimal(12,4) DEFAULT NULL, `reward_currency_amount` decimal(12,4) DEFAULT NULL, `base_reward_currency_amount_invoiced` decimal(12,4) DEFAULT NULL, `reward_currency_amount_invoiced` decimal(12,4) DEFAULT NULL, `base_reward_currency_amount_refunded` decimal(12,4) DEFAULT NULL, `reward_currency_amount_refunded` decimal(12,4) DEFAULT NULL, `reward_points_balance_refunded` int(10) unsigned DEFAULT NULL, `reward_points_balance_to_refund` int(10) unsigned DEFAULT NULL, `reward_salesrule_points` int(10) unsigned DEFAULT NULL, `note` text, `floor` text, `not_use_rise_on_floor` text, `shipping_cost` text, `rise_on_floor_cost` text, `service_charge_cost` decimal(12,4) NOT NULL DEFAULT '0.0000', `registration_address` text, `residential_address` text, `work` text, `work_address` text, `name_third` text, `phone_third` text, `passport_number` text, `passport_from` text, `inn_from` text, `inn` text, `inn_date` date DEFAULT NULL, `passport_date` date DEFAULT NULL, `initial_fee` int(11) DEFAULT '0', `credit_status` int(11) DEFAULT '0', `work_phone` text, `erp_code` varchar(15) DEFAULT NULL, `erp_changed` tinyint(1) NOT NULL DEFAULT '0', `user_group` varchar(25) DEFAULT NULL, `shipping_time` varchar(50) DEFAULT NULL, PRIMARY KEY (`entity_id`), UNIQUE KEY `UNQ_INCREMENT_ID` (`increment_id`), KEY `IDX_STATUS` (`status`), KEY `IDX_STATE` (`state`), KEY `IDX_STORE_ID` (`store_id`), KEY `IDX_CREATED_AT` (`created_at`), KEY `IDX_CUSTOMER_ID` (`customer_id`), KEY `IDX_EXT_ORDER_ID` (`ext_order_id`), KEY `IDX_UPDATED_AT` (`updated_at`), KEY `IDX_QUOTE_ID` (`quote_id`), CONSTRAINT `FK_SALES_FLAT_ORDER_CUSTOMER` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `FK_SALES_FLAT_ORDER_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=366444 DEFAULT CHARSET=utf8 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.07.2013, 20:29:44
|
|||
|---|---|---|---|
|
|||
Не хочет использовать индексы в простом запросе |
|||
|
#18+
АлександрТТДобрый день. Проблема в том что MySQL не хочет использовать индексы в запросе. Подскажите в чем дело или что почитать, запрос вроди бы простой... Пытался уже и limit ставить и null убирать, ранее по умолчанию для поля был null. Вобщим помогите пожалуйста уважаемые коллеги. Запрос: Код: sql 1. Выполняется времени: 1 row in set (2.62 sec) Описание запроса: Код: sql 1. 2. 3. 4. 5. 6. Записей в таблице: 366104 Из desc sales_flat_order: Код: sql 1. 2. 3. 4. 5. ... поле - строковое, ищете по нему - число, даа одного этого уже достаточно... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.07.2013, 22:18:41
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
То есть закавычив условие increment_id="100358224" запрос убыстрицца? :) --- Чего только не насмотришься на форумах... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.07.2013, 22:31:00
|
|||
|---|---|---|---|
|
|||
Не хочет использовать индексы в простом запросе |
|||
|
#18+
debloggerТо есть закавычив условие increment_id="100358224" запрос убыстрицца? :) --- Чего только не насмотришься на форумах... что такое "конвертация типов", пхп-писатель в курсе ? ------ по большому счёту, сервер должен был бы, просто, "посылать" с такими "запросами" , и это было бы правильно .... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.07.2013, 23:57:42
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
qwerty112, Писатель конечно в курсе что выражение $a = 1; фундаментально означает преобразование типов, но очень сомневается что драйвер будет конвертить текст в число, а потом обратно обнаружа типа текстовое поле при каждом обращении к полю в процессе выполнения запроса. Тут скорее всего дело в самой портянке. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.07.2013, 00:03:17
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
Да и вообще это конверчение мгновенная операция. Сколько там цифр - 10? Значит 10 раз замаскировать и сложить что осталось от маски. Текстовый 0 это 0030, 1 == 0031 и так далее. ABCDEF - аналогично: 0041, 0041 и так далее. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.07.2013, 00:38:26
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
RTFM: Код: plaintext 1. 2. 3. 4. делайте в кавычках или CAST и не морочите бабушке бейтцы. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.07.2013, 05:52:27
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
Прелестно, именно так и получается что конвертится значение поля под тип в запросе. Видимо какое-то историческое наследие. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.07.2013, 05:57:37
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
debloggerПрелестно, именно так и получается что конвертится значение поля под тип в запросе.Вовсе нет. Просто чар к инту можно привести однозначно, а вот наоборот - нет. Код: plaintext ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.07.2013, 07:52:26
|
|||
|---|---|---|---|
Не хочет использовать индексы в простом запросе |
|||
|
#18+
tanglir, Забавно, не знал. Всегда стараюсь делать явное преобразование типов не полагаясь на "умолчания"... может поэтому и не сталкивался. У меня бы запрос сразу приобрел вид WHERE field = "1" можно сказать "автоматически" (не задумываясь). Пасибки, а ведь верно. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|

start [/forum/topic.php?fid=47&mobile=1&tid=1836395]: |
0ms |
get settings: |
10ms |
get forum list: |
13ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
51ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
33ms |
get tp. blocked users: |
1ms |
| others: | 245ms |
| total: | 367ms |

| 0 / 0 |
