why the sql so slowly?

why the sql so slowly?

am 17.06.2010 06:35:13 von hewei

--001636c5a79c7835330489325e91
Content-Type: text/plain; charset=ISO-8859-1

now , I need to select a table per minute.
1.
the table struture:
------------------------------------------------------------ -----
CREATE TABLE `table_code` (
`timestamp` timestamp NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
`code` decimal(5,0) NOT NULL default '0',
PRIMARY KEY (`stock_code`)
)
------------------------------------------------------------ -----
2.
there is a trigger will insert data into the table `table_code`
the trigger is like:
------------------------------------------------------------ -----
if .... then
insert into table_code....
end if;
------------------------------------------------------------ -----
3.
I need to select the table 'table_code' per minute,and the sql is like :
select code from table_code;

now, the problem is:
in normally,the sql executed very fast (0.5-1 second), but sometimes, it
will take more than 3 minutes. I don't know
why? how to find the cause?

--001636c5a79c7835330489325e91--

Re: why the sql so slowly?

am 17.06.2010 08:47:42 von Ananda Kumar

--000e0cd5d1da1b5c180489343761
Content-Type: text/plain; charset=ISO-8859-1

How many records are there in this table.
What is the select statement ur running.

regards
anandkl

On Thu, Jun 17, 2010 at 10:05 AM, hewei wrote:

> now , I need to select a table per minute.
> 1.
> the table struture:
> ------------------------------------------------------------ -----
> CREATE TABLE `table_code` (
> `timestamp` timestamp NULL default CURRENT_TIMESTAMP on update
> CURRENT_TIMESTAMP,
> `code` decimal(5,0) NOT NULL default '0',
> PRIMARY KEY (`stock_code`)
> )
> ------------------------------------------------------------ -----
> 2.
> there is a trigger will insert data into the table `table_code`
> the trigger is like:
> ------------------------------------------------------------ -----
> if .... then
> insert into table_code....
> end if;
> ------------------------------------------------------------ -----
> 3.
> I need to select the table 'table_code' per minute,and the sql is like :
> select code from table_code;
>
> now, the problem is:
> in normally,the sql executed very fast (0.5-1 second), but sometimes, it
> will take more than 3 minutes. I don't know
> why? how to find the cause?
>

--000e0cd5d1da1b5c180489343761--

Re: why the sql so slowly?

am 17.06.2010 10:35:21 von hewei

--0016e65097f050a974048935b9f8
Content-Type: text/plain; charset=ISO-8859-1

1.How many records are there in this table.
==>6000 rows.

2.What is the select statement ur running.
==>
-------------------------------
I need to select the table 'table_code' per minute,and the sql is like :
select code from table_code;
-------------------------------

--0016e65097f050a974048935b9f8--

Re: why the sql so slowly?

am 17.06.2010 11:37:32 von Ananda Kumar

--001636e1f8467f89bc0489369663
Content-Type: text/plain; charset=ISO-8859-1

you want to select all rows from the table

On Thu, Jun 17, 2010 at 2:05 PM, hewei wrote:

> 1.How many records are there in this table.
> ==>6000 rows.
>
> 2.What is the select statement ur running.
> ==>
> -------------------------------
>
> I need to select the table 'table_code' per minute,and the sql is like :
> select code from table_code;
> -------------------------------
>

--001636e1f8467f89bc0489369663--

Re: why the sql so slowly?

am 17.06.2010 12:54:23 von hewei

--0016367b6f7a7a2734048937aa64
Content-Type: text/plain; charset=ISO-8859-1

you want to select all rows from the table?

===> YES

--0016367b6f7a7a2734048937aa64--

Re: why the sql so slowly?

am 19.07.2010 11:52:48 von Nguyen Manh Cuong

Try Explain command before execute something
Please google how to use index


----- Original Message -----
From: "hewei"
To: "Ananda Kumar"
Cc: mysql@lists.mysql.com
Sent: Thursday, June 17, 2010 5:54:23 PM
Subject: Re: why the sql so slowly?

you want to select all rows from the table?

===> YES

--
Best Regards,
Cuongmc.

--
Nguyen Manh Cuong
Phong Ky Thuat - Cong ty Vien Thong So - VTC
Dien thoai: 0912051542
Gmail : philipscuong@gmail.com
YahooMail : philipscuong@yahoo.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org