මචන්ල පුලුවන් නම් මේකට හෙල්ප් එකක්
MYSQL table එකක් තියෙනව 1M Records.
මේකෙ ptype වර්ග 10ක් විතර තියෙනව. Ex - Inventory, Raw, etc ...
මේ table එකට select query ලිව්වාම (without limit) type එකක් විතරක් select කරගන්න execution time avg 2.2s.
types ගාන වැඩි වෙනකොට execution time එකත් වැඩි වෙනව.
execution time avg 3.3s.
execution time avg 4.6s.
ඒ නිසා මම ptype එකට index එකක් දැන්ම.
දැන් Where clause එකේ ptype දෙකක් හෝ වැඩි ගානක් තිබ්බාම execution time එක පොඩ්ඩක් අඩු උනත් තනි where clause එකේදි time එක ඩබල් වෙනව.
execution time avg 4.3s
.
මේකට හොදම විසදුමක් පුලුවන් කෙනෙක් කියන්නකො
MYSQL table එකක් තියෙනව 1M Records.
Code:
CREATE TABLE `products` (
`pid` INT(6) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(200) NOT NULL,
`ptype` VARCHAR(10) NOT NULL,
PRIMARY KEY (`pid`)
)
මේ table එකට select query ලිව්වාම (without limit) type එකක් විතරක් select කරගන්න execution time avg 2.2s.
Code:
SELECT * FROM products WHERE ptype = 'Inventory'
Code:
SELECT * FROM products WHERE ptype = 'Inventory' OR ptype = 'Raw'
Code:
SELECT * FROM products WHERE ptype = 'Inventory' OR ptype = 'Raw' OR ptype = 'Service'
ඒ නිසා මම ptype එකට index එකක් දැන්ම.
Code:
CREATE INDEX PTYPE_INDEX ON products (ptype)
Code:
SELECT * FROM products WHERE ptype = 'Inventory'
.
මේකට හොදම විසදුමක් පුලුවන් කෙනෙක් කියන්නකො



int karana ekath hodai
නිත් එක බන් හැම එකටම ඉන්ඩෙක්ස් දැම්ම කියල වැඩක් නැහැ...

බැරි උනොත් ලොකු සර්වර් එකට මූව් කරපන්...සර්ව එකේ බෆර් පූල් සයිස් එකත් වැඩි කරන්න පුලුවන්නම්...එතකොට රැම් එකෙන් රීඩ් කරන එක ලේසි වෙනවා...

