Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Slow Speed In read Data By This SQL
Mon, Apr 27 2009 2:06 PMPermanent Link

Kianian.mehrdad@gmail.com
Hi,
I Use ElevateDB Standalone Edition
This SQL needs 5 to 10 Second time to return result :
rows count are 300

                            Select * ,
                           (Select Count(*) from student where stid > 0  ) as Count1 ,
                           (Select Count(*) from student where stid > 50  ) as Count2 ,
                           (Select Count(*) from student where stid > 100  ) as Count3 ,
                           from student
                            order by stid
Tue, Apr 28 2009 12:31 PMPermanent Link

"James Relyea"
> This SQL needs 5 to 10 Second time to return result :
> rows count are 300=20
>=20
>                             Select * ,
>                            (Select Count(*) from student where stid > =
0  ) as Count1 ,
>                            (Select Count(*) from student where stid > =
50  ) as Count2 ,
>                            (Select Count(*) from student where stid > =
100  ) as Count3 ,
>                            from student=20
>                             order by stid

I'm not sure if this would change anything, but have you tried this as =
an alternate? I intentionally dropped the sort.
                            Select * ,
                           (Select Count(stid) from student where stid =
> 0  ) as Count1 ,
                           (Select Count(stid) from student where stid =
> 50  ) as Count2 ,
                           (Select Count(stid) from student where stid =
> 100  ) as Count3 ,
                           from student=20

Smile
jr
Tue, Apr 28 2009 2:37 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< I Use ElevateDB Standalone Edition
This SQL needs 5 to 10 Second time to return result :
rows count are 300  >>

Is there an index on the stid column in the student table ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Apr 29 2009 4:06 AMPermanent Link

mkalone@gmail.com
Sorry This is The Main SQL :


  Select * ,            (Select Count(*) from SMSNumbers where SMSNumbers .messageId_fk =
Messages.Id ) as CountAll ,
                           (Select Count(*) from SMSNumbers where SMSNumbers
.messageId_fk = Messages.Id AND status = 3) as CountSuccessed ,
                           (Select Count(*) from SMSNumbers where SMSNumbers
.messageId_fk = Messages.Id AND status = 2) as CountFailed
                           from Messages
                           order by Id desc

We Have 2 Tables  :  SMSNumbers , Messages

SMSNumber Contains 3000 to 3000000 record per  Messages Table Record
When I Run The Count Individually no problem
but in this SQL Syntax  has low Speed.

Tow Tables has Primary KEY
Wed, Apr 29 2009 4:15 AMPermanent Link

mkalone@gmail.com
Solved.
when i add Foreign Key Constraint,
My Query runs quick.
Wed, Apr 29 2009 2:17 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< Solved.
when i add Foreign Key Constraint,
My Query runs quick. >>

Yes, you were probably missing an index on the messageId_fk column in the
SMSNumbers table.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image