I have the following query:
SELECT * FROM scheme.table cont WHERE game_id = 'some-game-id' AND event_arrival_time BETWEEN '2019-12-02 00:00:00' AND '2019-12-31 23:59:59' ORDER BY event_arrival_time
I get response time of almost 30 seconds
for the same query if I remove ORDER BY event_arrival_time i get the response in few seconds
This is the create table query:
CREATE TABLE `cont_event` ( `event_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `action` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `correlation_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `event_arrival_time` datetime DEFAULT NULL, `create_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, `create_ts` bigint(20) DEFAULT NULL, `operator_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `game_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `player_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `segment_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `bet_amount_original` decimal(15,4) DEFAULT NULL, `bet_amount_converted` decimal(15,4) DEFAULT NULL, `cont_amount_player` decimal(15,4) DEFAULT NULL, `cont_amount_operator` decimal(15,4) DEFAULT NULL, `cont_amount_total` decimal(15,4) DEFAULT NULL, `operator_income` decimal(15,4) DEFAULT NULL, `cont_amount_jackpot` decimal(15,4) DEFAULT NULL, `original_currency` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `base_currency` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `currency_rate` decimal(20,6) DEFAULT NULL, `operator_game_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `funnel_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `segment_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `operator_game_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `extra_fields` longtext CHARACTER SET utf8 COLLATE utf8_general_ci, `jackpot_game_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `game_version` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `event_type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `event` JSON COLLATE utf8_bin, KEY `operator_id` (`event_arrival_time`,`action`,`operator_id`,`game_id`,`correlation_id`) /*!90619 USING CLUSTERED COLUMNSTORE */ /*!90618 , SHARD KEY () */ ) /*!90621 AUTOSTATS_ENABLED=TRUE */
i do have index on: event_arrival_time, action, operator_id, game_id, correlation_id
when doing memsql profile i can see the filter works fine(see attached):
iam not sure what am I missing? any suggestions for optimization?
Here is your first query repeated:
SELECT *
FROM scheme.table cont
WHERE
game_id = 'some-game-id' AND
event_arrival_time BETWEEN '2019-12-02 00:00:00' AND '2019-12-31 23:59:59'
ORDER BY
event_arrival_time
The index you have currently defined looks either wrong to me, or at least sub-optimal. Try the following index instead:
CREATE INDEX idx ON cont (event_arrival_time, game_id);
Ideally, MemSQL would be able to scan the above index, in the order of the event arrival time, in the range you defined, and retrieve all matching records.
Related
Need help please.
I have excel files where some sheets are as follows:
enter image description here
enter image description here
I need to insert into the db table the matching columns from the excel file but for example WID and eename are both under column J and status column is in N but some sheets end at M.
When I print column names this is what I get:
ToPay,CompEntity,ProjectName,Details,Amount,Invoicenumber,PayInCurrency,PayOutCurrency,Paymentdate,PaidFrom,Addedby,Unnamed:13,Status
def readfile(self):
filepath = 'MatchPoin EUR - PT123.xlsx'
df1 = pd.read_excel(filepath, sheet_name=None, usecols="A,B,C,E,F,G,H,I,K,L,M,N")
df2 = pd.concat(df1, ignore_index=True)
return df2
def insert_to_db(self, df):
conn = self.db[0]
cursor = self.db[1]
col_list = df.columns.str.replace(' ', '')
insert_columns = ",".join(col for col in col_list)
print(insert_columns)
index_list = []
for _ in col_list:
index_list.append("%s")
index_str = ",".join(index for index in index_list)
values_list = df.values
insert_values_list = [tuple(values) for values in values_list]
num_rows_inserted = 0
# query = f"""insert into suppay_payments_stagingtable ({insert_columns}) values({index_str})"""
# print (insert_values_list)
for k, v in enumerate(insert_values_list):
try:
cursor.callproc('ins_beneficiaryfromfiles', v)
num_rows_inserted = num_rows_inserted + cursor.rowcount
conn.commit()
except Exception as e:
conn.rollback()
print(e)
logging.error(e)
My database table:
CREATE TABLE `suppay_payments_stagingtable` (
`payID` int(11) NOT NULL AUTO_INCREMENT,
`toPay` varchar(100) DEFAULT NULL,
`papayaEntityName` varchar(200) DEFAULT NULL,
`projectID` varchar(100) DEFAULT NULL,
`projectName` varchar(200) DEFAULT NULL,
`details` varchar(200) DEFAULT NULL,
`amount` decimal(10,3) DEFAULT NULL,
`invoiceNumber` varchar(50) DEFAULT NULL,
`payInCurrency` varchar(5) DEFAULT NULL,
`payOutCurrency` varchar(5) DEFAULT NULL,
`paymentDate` varchar(200) DEFAULT NULL,
`paidFrom` varchar(500) DEFAULT NULL,
`addedBy` varchar(200) DEFAULT NULL,
`WID` varchar(50) DEFAULT NULL,
`status` varchar(50) DEFAULT NULL,
`eename` varchar(50) DEFAULT NULL,
`bookKeepingNotes` varchar(200) DEFAULT NULL,
`noteDateBookeeping` date DEFAULT NULL,
`underOverPayment` varchar(200) DEFAULT NULL,
`opsNotes` varchar(200) DEFAULT NULL,
`opsNoteDate` varchar(200) DEFAULT NULL,
`sourcefilename` varchar(1000) DEFAULT NULL,
`sheetname` varchar(20) DEFAULT NULL,
`beneficiaryname` varchar(200) DEFAULT NULL,
`beneficiarycode` varchar(20) DEFAULT NULL,
`createdAt` datetime DEFAULT current_timestamp(),
`updateAt` datetime DEFAULT current_timestamp(),
`deposit` varchar(100) DEFAULT NULL,
PRIMARY KEY (`payID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
We are using single node MemSQL and everything was working fine but when we are trying to move our MemSQL setup to use multi node the insert/update statements are behaving very weirdly
My table structures are like below , have removed many columns , to keep it short
CREATE /*!90618 REFERENCE*/ TABLE `fact_orderitem_hourly_release_update`
(
`order_id` int(11) NOT NULL DEFAULT '0',
`customer_login` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`warehouse_id` int(11) DEFAULT NULL,
`city` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`store_id` int(11) DEFAULT NULL,
PRIMARY KEY (`order_id`)
);
CREATE TABLE `fact_orderitem_hourly_scale` (
`order_id` int(11) NOT NULL DEFAULT '0',
`order_group_id` int(11) NOT NULL DEFAULT '0',
`item_id` int(11) NOT NULL,
`sku_id` int(11) NOT NULL DEFAULT '0',
`sku_code` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`po_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`store_order_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`bi_last_modified_on` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
PRIMARY KEY (`item_id`,`sku_id`),
/*!90618 SHARD */ KEY `sku_id` (`sku_id`),
KEY `idx_fact_orderitem_hourly_lmd` (`bi_last_modified_on`),
KEY `idx_fact_orderitem_hourly_ord` (`order_id`),
KEY `idx_order_group_id` (`order_group_id`),
KEY `idx_store_order_id` (`store_order_id`)
);
My Load Script :
mysql -h$LiveMemSQL_DB -u$LiveMemSQL_USER --password=$LiveMemSQL_PASS -P$LiveMemSQL_PORT --verbose reports_and_summary < /home/titan/brand_catalog/upsert_memsql_orl_update.sql
Contents of .SQL File :
--start of .sql file
TRUNCATE TABLE reports_and_summary.fact_orderitem_hourly_release_update;
#Load data into staging
LOAD DATA LOCAL INFILE '/myntra/redshift/delta_files/live_scale_order_release_upd.txt' INTO TABLE reports_and_summary.fact_orderitem_hourly_release_update LINES TERMINATED BY '\n';
#Insert/Update statement
INSERT INTO reports_and_summary.fact_orderitem_hourly_scale
(
item_id,
sku_id,
customer_login,
order_status,
is_realised,
is_shipped,
shipping_charge,
gift_charge,
warehouse_id,
city,
store_id
)
select
fo.item_id,
fo.sku_id,
fr.customer_login,
fr.order_status,
fr.is_realised,
fr.is_shipped,
fr.shipping_charge,
fr.gift_charge,
fr.warehouse_id,
fr.city,
fr.store_id
from fact_orderitem_hourly_release_update fr
join fact_orderitem_hourly_scale fo
on fr.order_id=fo.order_id
ON duplicate key update
customer_login=values(customer_login),
order_status=values(order_status),
is_realised=values(is_realised),
is_shipped=values(is_shipped),
shipping_charge=values(shipping_charge),
gift_charge=values(gift_charge),
warehouse_id=values(warehouse_id),
city=values(city),
store_id=values(store_id);
--End .sql file
When I trigger the above .sql through mysql command line client , it works sometimes and it doesn't many of times , and some times if I execute the same .sql file continuously 5-10 times , the updates will get effected in one of those runs , and sometimes say for example if there are 3 records with order_id 101 and status SHIPPED and we got an update in merge table say the order status has been changed to DELIVERED , ideally status of all 3 orders should be changed to DELIVERED , but only one or 2 of the rows associated with an order are getting updated but if I execute the same .sql file content through MySQLWorkbench it works perfectly fine , I may sound stupid , but this is what is happening and I am struggling from last 2 days with this weird behavior
Please find the below screen cast , where I captured this behaviour https://www.youtube.com/watch?v=v2HN-n4V0MI&feature=youtu.be
Your staging table is a reference table, and writes to reference tables are replicated asynchronously to the cluster. This is why sometimes your updates work as expected and sometimes they don't.
You can
wait for a bit after writing into the reference table
make the staging table non-reference
We are using memsql 5.1 for a web-analytics project. There is about 80M records and 0,5M records per day. A simple request works about 5 seconds - how many data was received per domain,geo,lang for a given day. I feel it is possible to reduce those time, but i cant find a way. Please tell me the way.
Tables like one
CREATE TABLE `domains` (
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`geo` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`lang` char(5) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`browser` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`os` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`device` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`domain` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`ref` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`blk_cnt` int(11) DEFAULT NULL,
KEY `date` (`date`,`geo`,`lang`,`domain`) /*!90619 USING CLUSTERED COLUMNSTORE */
/*!90618 , SHARD KEY () */
)
request like this one:
memsql> explain SELECT domain, geo, lang, avg(blk_cnt) as blk_cnt, count(*) as cnt FROM domains WHERE date BETWEEN '2016-07-31 0:00' AND '2016-08-01 0:00' GROUP BY domain, geo, lang ORDER BY blk_cnt ASC limit 40;
+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN |
+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project [r0.domain, r0.geo, r0.lang, $0 / CAST(COALESCE($1,0) AS SIGNED) AS blk_cnt, CAST(COALESCE($2,0) AS SIGNED) AS cnt] |
| Top limit:40 |
| GatherMerge [SUM(r0.s) / CAST(COALESCE(SUM(r0.c),0) AS SIGNED)] partitions:all est_rows:40 |
| Project [r0.domain, r0.geo, r0.lang, s / CAST(COALESCE(c,0) AS SIGNED) AS blk_cnt, CAST(COALESCE(cnt_1,0) AS SIGNED) AS cnt, s, c, cnt_1] est_rows:40 |
| TopSort limit:40 [SUM(r0.s) / CAST(COALESCE(SUM(r0.c),0) AS SIGNED)] |
| HashGroupBy [SUM(r0.s) AS s, SUM(r0.c) AS c, SUM(r0.cnt) AS cnt_1] groups:[r0.domain, r0.geo, r0.lang] |
| TableScan r0 storage:list stream:no |
| Repartition [domains.domain, domains.geo, domains.lang, cnt, s, c] AS r0 shard_key:[domain, geo, lang] est_rows:40 est_select_cost:144350216 |
| HashGroupBy [COUNT(*) AS cnt, SUM(domains.blk_cnt) AS s, COUNT(domains.blk_cnt) AS c] groups:[domains.domain, domains.geo, domains.lang] |
| Filter [domains.date >= '2016-07-31 0:00' AND domains.date <= '2016-08-01 0:00'] |
| ColumnStoreScan scan_js_data.domains, KEY date (date, geo, lang, domain) USING CLUSTERED COLUMNSTORE est_table_rows:72175108 est_filtered:18043777 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------+
After application of the recommendations
time of original query - 5s
with timestamp optimization - 3.7s
with timestamp+shardkey - 2.6s
Thank you very match!
Executing the group by is probably the most expensive part of this query. Using shard key that matches the group by, i.e. SHARD KEY (domain, geo, lang), will allow the group by to be executed faster.
I'm trying to get my database within my application to search by phone numbers. I've got to the "Search Criteria Builder" screen, but I can't seem to get my query right.
This is the query I've tried and that is when I get the "converting from nvarchar to numeric" error:
SELECT phoneNumber, serviceDate, firstName, lastName, billingAddress, emailAddress, vehicleMake, vehicleModel, vehicleYear, vehicleColor, vehicleMileage
FROM [Table]
WHERE (phoneNumber LIKE #phoneNumber + N'%')
Here is the table created:
CREATE TABLE [dbo].[Table] (
[phoneNumber] NUMERIC (18) NOT NULL,
[serviceDate] DATE NULL,
[firstName] NCHAR (10) NULL,
[lastName] NCHAR (10) NULL,
[billingAddress] NVARCHAR (50) NULL,
[emailAddress] NVARCHAR (50) NULL,
[vehicleMake] NCHAR (10) NULL,
[vehicleModel] NCHAR (10) NULL,
[vehicleYear] INT NULL,
[vehicleColor] NCHAR (10) NULL,
[vehicleMileage] INT NULL,
CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED ([phoneNumber] ASC)
);
If the VB code is needed, I will provide it as well.
If you're going to treat phone "numbers" like strings, why are you storing them as numeric? You can do this:
WHERE CONVERT(VARCHAR(32), phoneNumber) LIKE #phonenumber + '%';
(Also note that you don't need Unicode here - there is no number with umlauts.)
But better to change the data type of the column IMHO.
IS there anyway i can improve this query?
SELECT DISTINCT adb_product_type.strproduct_type AS strproduct_type, adb_product_cat.strproduct_cat AS strproduct_cat, adb_product.strproduct AS strproduct,
CASE #campaignCount:=
(SELECT COUNT(DISTINCT adb_campaign_1.campaign_id)
FROM adb_camp_media AS adb_camp_media_1
LEFT JOIN adb_campaign AS adb_campaign_1 ON adb_campaign_1.campaign_id = adb_camp_media_1.campaign_id
LEFT JOIN adb_camp_media_prod AS adb_camp_media_prod_1 ON adb_camp_media_prod_1.media_num = adb_camp_media_1.media_num
WHERE
(adb_camp_media_1.inttotal_per_store = 1 AND adb_camp_media_1.lngproduct = adb_product.lngproduct OR adb_camp_media_1.inttotal_per_store > 1 AND adb_camp_media_prod_1.lngproduct = adb_product.lngproduct)
AND (
(
adb_campaign_1.start_date
BETWEEN '2011-01-01'
AND '2011-01-31'
)
OR (
adb_campaign_1.end_date
BETWEEN '2011-01-01'
AND '2011-01-31'
)
OR (
adb_campaign_1.start_date < '2011-01-01'
AND adb_campaign_1.end_date > '2011-01-31'
)
)
)
WHEN 0 THEN 'No' ELSE 'Yes' END AS 'YesNo',
CASE #campaignCount WHEN 0 THEN '' ELSE #campaignCount END AS 'CampaignCount',
CASE #campaignCount WHEN 0 THEN '' ELSE
(SELECT GROUP_CONCAT(DISTINCT adb_media_1.name ORDER BY adb_media_1.name SEPARATOR ', ' )
FROM adb_camp_media AS adb_camp_media_1
LEFT JOIN adb_campaign AS adb_campaign_1 ON adb_campaign_1.campaign_id = adb_camp_media_1.campaign_id
LEFT JOIN adb_camp_media_prod AS adb_camp_media_prod_1 ON adb_camp_media_prod_1.media_num = adb_camp_media_1.media_num
LEFT JOIN adb_media AS adb_media_1 ON adb_media_1.media_id = adb_camp_media_1.media_id
WHERE
(adb_camp_media_1.inttotal_per_store = 1 AND adb_camp_media_1.lngproduct = adb_product.lngproduct OR adb_camp_media_1.inttotal_per_store > 1 AND adb_camp_media_prod_1.lngproduct = adb_product.lngproduct)
AND (
(
adb_campaign_1.start_date
BETWEEN '2011-01-01'
AND '2011-01-31'
)
OR (
adb_campaign_1.end_date
BETWEEN '2011-01-01'
AND '2011-01-31'
)
OR (
adb_campaign_1.start_date < '2011-01-01'
AND adb_campaign_1.end_date > '2011-01-31'
)
)
)
END AS mediaName , adb_product.lngproduct
FROM adb_product_type
LEFT JOIN adb_product_cat ON adb_product_cat.lngproduct_type = adb_product_type.lngproduct_type
LEFT JOIN adb_product ON adb_product.lngproduct_cat = adb_product_cat.lngproduct_cat
LEFT JOIN adb_camp_media ON adb_camp_media.lngproduct = adb_product.lngproduct
LEFT JOIN adb_media ON adb_media.media_id = adb_camp_media.media_id
LEFT JOIN adb_camp_media_prod ON adb_camp_media_prod.media_num = adb_camp_media.media_num
LEFT JOIN adb_campaign ON adb_campaign.campaign_id = adb_camp_media.campaign_id
WHERE 1=1
ORDER BY YesNo DESC , strproduct_type, strproduct_cat, strproduct
TABLE STRUCTURE
-- Table structure for table adb_camp_media
CREATE TABLE adb_camp_media (
media_num int(11) NOT NULL auto_increment,
campaign_id int(11) NOT NULL default '0',
media_id int(11) NOT NULL default '0',
inttotal_per_store int(4) NOT NULL default '0',
units_per_item int(2) default NULL,
lngproduct int(11) NOT NULL default '0',
rental_cost double(10,2) default NULL,
checkers_rental double default NULL,
hyper_rental double default NULL,
usave_rental double default NULL,
ls_rental double(10,2) default '0.00',
spar_rental double(10,2) default '0.00',
backboard tinyint(1) NOT NULL,
PRIMARY KEY (media_num),
KEY campaign_id (campaign_id,media_id,lngproduct),
KEY lngproduct (lngproduct)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table adb_camp_media_prod
CREATE TABLE adb_camp_media_prod (
media_prod_id int(11) NOT NULL auto_increment,
media_num int(4) NOT NULL,
lngproduct int(4) NOT NULL,
PRIMARY KEY (media_prod_id),
KEY media_num (media_num,lngproduct),
KEY lngproduct (lngproduct)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table adb_campaign
CREATE TABLE adb_campaign (
campaign_id int(11) NOT NULL auto_increment,
client_id int(11) NOT NULL default '0',
campaign_name varchar(50) NOT NULL default '',
description text,
position_desc text,
start_date date NOT NULL default '0000-00-00',
end_date date NOT NULL default '0000-00-00',
approved tinyint(1) NOT NULL default '0',
created_date date NOT NULL default '0000-00-00',
updated_date datetime default NULL,
user_id int(11) NOT NULL default '0',
pinno varchar(50) NOT NULL default '',
jobno varchar(30) NOT NULL default '',
quoteno varchar(30) NOT NULL default '',
sales_ae_id int(11) default NULL,
artwork_specno varchar(30) NOT NULL default '',
artwork_jobno varchar(30) NOT NULL default '',
agency tinyint(1) NOT NULL default '0',
brand_name varchar(50) NOT NULL default '',
paypercycle tinyint(1) NOT NULL default '0',
agency_comm double default NULL,
variant varchar(100) default NULL,
pack_size varchar(100) default NULL,
discount double default NULL,
discount_val double default NULL,
sales_comm double NOT NULL default '0',
cancelled tinyint(1) default '0',
onhold tinyint(1) default '0',
campaign_status_id int(4) default NULL,
PRIMARY KEY (campaign_id),
UNIQUE KEY jobno (jobno),
KEY start_date (start_date),
KEY end_date (end_date),
KEY campaign_name (campaign_name),
KEY user_id (user_id,cancelled,onhold)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table adb_product
CREATE TABLE adb_product (
lngproduct int(11) NOT NULL auto_increment,
strproduct varchar(100) NOT NULL default '',
lngproduct_cat int(11) NOT NULL default '0',
PRIMARY KEY (lngproduct),
KEY lngproduct_cat (lngproduct_cat)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table adb_product_cat
CREATE TABLE adb_product_cat (
lngproduct_cat int(11) NOT NULL auto_increment,
strproduct_cat varchar(100) NOT NULL default '',
lngproduct_type int(11) NOT NULL default '0',
PRIMARY KEY (lngproduct_cat),
KEY lngproduct_type (lngproduct_type)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table adb_product_type
CREATE TABLE adb_product_type (
lngproduct_type int(11) NOT NULL auto_increment,
strproduct_type varchar(100) NOT NULL default '',
PRIMARY KEY (lngproduct_type)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;