Commit 1764ba15 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Some optimization. Here are the details:

* SQLDict_assignMessage.zsql

Avoid unnecessary assignments. Reduce message size.

* SQLDict_setPriority.zsql

Reduce message size.

* SQLDict_readMessageList.zsql

Remove unnecessary GROUP BY.
Add uid into ORDER BY so that messages are enumerated
mostly in the order of insertions, which potentially reduces
chances that messages will be reordered later.

* SQLDict_readMessage.zsql

Use DISTINCT and GROUP BY, only if necessary.
Add uid into ORDER BY for the same reason as above.

* SQLDict_createMessageTable.zsql

Specify NOT NULL whenever possible to reduce data size.
Use SMALLINT instead of INT for processing_node to reduce data size.
Remove useless indexes to reduce the cost of UPDATE.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13582 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent da611485
......@@ -17,11 +17,13 @@ SET
processing_node=<dtml-sqlvar processing_node type="int">,
processing=0
WHERE
processing_node = -1
<dtml-if uid>
<dtml-in uid>uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else>
OR </dtml-if></dtml-in>
AND uid IN (
<dtml-in uid><dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
)
<dtml-else>
path = <dtml-sqlvar path type="string">
AND path = <dtml-sqlvar path type="string">
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
</dtml-if>
<dtml-if broadcast>
......
......@@ -9,28 +9,26 @@ class_file:
</dtml-comment>
<params></params>
CREATE TABLE `message` (
`uid` INT UNSIGNED NOT NULL auto_increment,
`date` datetime,
`path` VARCHAR(255),
`method_id` VARCHAR(255),
`processing_node` INT DEFAULT -1,
`processing` TINYINT DEFAULT 0,
`processing_date` datetime,
`priority` TINYINT DEFAULT 0,
`broadcast` TINYINT DEFAULT 0,
`group_method_id` VARCHAR(255) DEFAULT '',
`tag` VARCHAR(255),
`uid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`date` DATETIME NOT NULL,
`path` VARCHAR(255) NOT NULL,
`method_id` VARCHAR(255) NOT NULL,
`processing_node` SMALLINT NOT NULL DEFAULT -1,
`processing` TINYINT NOT NULL DEFAULT 0,
`processing_date` DATETIME,
`priority` TINYINT NOT NULL DEFAULT 0,
`broadcast` TINYINT NOT NULL DEFAULT 0,
`group_method_id` VARCHAR(255) NOT NULL DEFAULT '',
`tag` VARCHAR(255) NOT NULL,
`retry` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`order_validation_text` VARCHAR(255),
`message` BLOB,
PRIMARY KEY (`uid`),
KEY `date` (`date`),
KEY `path` (`path`),
KEY `method_id` (`method_id`),
KEY `processing_node` (`processing_node`),
KEY `processing` (`processing`),
KEY `processing_date` (`processing_date`),
KEY `priority` (`priority`),
KEY `tag` (`tag`),
KEY `order_validation_text` (`order_validation_text`)
`order_validation_text` VARCHAR(255) NOT NULL,
`message` BLOB NOT NULL,
PRIMARY KEY (`uid`),
KEY (`path`),
KEY (`method_id`),
KEY (`processing_node`),
KEY (`processing`),
KEY (`priority`),
KEY (`tag`),
KEY (`order_validation_text`)
) TYPE = InnoDB;
......@@ -13,7 +13,7 @@ to_date
to_processing_date
group_method_id
order_validation_text</params>
SELECT DISTINCT * FROM
SELECT <dtml-if group_method_id>DISTINCT</dtml-if> * FROM
message
WHERE
processing <> 1
......@@ -22,11 +22,12 @@ WHERE
<dtml-if to_date>AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if>
<dtml-if group_method_id>AND group_method_id = <dtml-sqlvar group_method_id type="string"> </dtml-if>
<dtml-if order_validation_text>AND order_validation_text = <dtml-sqlvar order_validation_text type="string"> </dtml-if>
<dtml-if group_method_id>
GROUP BY
path, method_id
</dtml-if>
ORDER BY
priority, date
priority, date, uid
<dtml-if group_method_id>
LIMIT 100
<dtml-else>
......
......@@ -34,7 +34,5 @@ WHERE
<dtml-if priority> AND priority = <dtml-sqlvar priority type="int"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"> </dtml-if>
<dtml-if method_id> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
GROUP BY
path, method_id, tag, processing_node, processing
ORDER BY
priority, date
priority, date, uid
......@@ -32,10 +32,8 @@ SET
WHERE
1 = 1
<dtml-if uid>
AND (
<dtml-in uid>
uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>
</dtml-in>
AND uid IN (
<dtml-in uid><dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
)
</dtml-if>
<dtml-if processing_node>
......@@ -43,4 +41,4 @@ WHERE
</dtml-if>
<dtml-if order_validation_text>
AND order_validation_text = <dtml-sqlvar order_validation_text type="string">
</dtml-if>
\ No newline at end of file
</dtml-if>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment