Jump to content
Server Maintenance This Week. ×

Why does it take forever to count records by SQL Query with particular condition when using FIleMaker?


This topic is 3575 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Why does it take forever to count with this SQL?

 

ExecuteSQL(

 "Select count(*)

  From TableName

  Where kanymd between '20140201' and '20140228'"

;"";""

)

 

btw, the format type of kanymd is based on Number, not date type.

 

 

For your information, it doesn't take time at all if I  try to Import records via ODBC with the same condition.

Also it takes less than a second if I do the same thing with MS Access.

 

Any advice?

Link to comment
Share on other sites

By using single quotes around the values, you are telling the db that it is text, not numbers.

 

Any difference if you try > and < instead of between?

 

Also: a little confused:  since you mention "import from ODBC", but at the same time use the ExecuteSQL() function: is this an ESS data source?

In that case, using ExecuteSQL on a TO from an ESS source has been reported to be slow in general because of the extra ESS layer.  The ExecuteSQL has to be translated and passed on to the external database and then back.

It may be faster to just do a find in FM and get the found count.

Link to comment
Share on other sites

Did you index: kanymd ?

 No, I haven't.

 

I think it doesn't really matter because it returns quick if I do "Import records from ODBC" with the same condition.

By using single quotes around the values, you are telling the db that it is text, not numbers.

 

Any difference if you try > and < instead of between?

 

Also: a little confused:  since you mention "import from ODBC", but at the same time use the ExecuteSQL() function: is this an ESS data source?

In that case, using ExecuteSQL on a TO from an ESS source has been reported to be slow in general because of the extra ESS layer.  The ExecuteSQL has to be translated and passed on to the external database and then back.

It may be faster to just do a find in FM and get the found count.

Thanks for an advice. I tried this now result returns "?"

It's so weird because indeed there are few records whose 'kanymd' are 20140201

 

ExecuteSQL(

 "Select count(*)

  From TableName

  Where kanymd = 20140201

;"";""

)

Link to comment
Share on other sites

Try:

ExecuteSQL(
 "Select count(*)
  From TableName
  Where kanymd >= ? AND kanymd <= ?"
;"";""; 
20140201 ; 20140228
)

"Between" can be really slow, I don't know why.

Link to comment
Share on other sites

This topic is 3575 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.