Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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?

Did you index: kanymd ?

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.

  • Author

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

;"";""

)

Try:

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

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.