Q:

cfquery taking forever to diaplay the output

Here is my problem:
I'm running the following cfquery and it's taking forever to display the output. 
SELECT Timestamp
FROM sgemaildata WHERE event_vc = "OPEN"  
AND mbTimestamp_dt >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_date"> 
AND mbTimestamp_dt <=  <cfqueryparam value="#dateAdd('d', 1, form.enddate)#" cfsqltype="cf_sql_date"> ;

Could you tell me how can I make it fast?

A:

There isn't anything obviously wrong with your cf code. 
If your table doesn't have this index, I suggest you try creating it.
 ALTER TABLE sgemaildata
 ADD INDEX   timequery_dex (event_vc, mbTimestamp_dt, Timestamp)

This will allow your query to be satisfied entirely by an index range scan, so it should perform well.
But beware, you'll incur some overhead when you insert rows into this table.
Somebody in the comments asked for more information about query time and display time.  If the result set for this query has tens of thousands of rows, it's going to take time to display no matter how much optimization you put into the query.

