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.

Any advice on improving performance of a multi join ExecuteSQL command?

Featured Replies

 

 

The below code takes 5-6 seconds to process (it's inside a webviewer).  Client machine is connected to local Filemaker Server over wireless network.

 

I'm trying to avoid creating a relationship just for this one usage, hence ExecuteSQL().  There is an intermediate table JoinClientsWebsites between Clients and Websites since some clients have the same website.

 

Could I do something differently to improve performance?

 

Thanks!

ExecuteSQL("
	SELECT url
	FROM Websites
	JOIN JoinClientsWebsites
		ON Websites.id=JoinClientsWebsites.id_websites
	JOIN Clients
		ON JoinClientsWebsites.id_clients=clients.id and JoinClientWebsites.primary='yes'
	WHERE Clients.id=?" ; "" ; "" ; Clients::id 
)

What version of FileMaker Server are you using?

  • Author

Server 13.0.1

Assuming you want the url of the primary web site for the specified client, the query can be a lot simpler.
 
ExecuteSQL("
  SELECT url
  FROM JoinClientsWebsites
  LEFT JOIN Websites ON Websites.id = JoinClientsWebsites.id_websites
  WHERE JoinClientsWebsites.primary = 'yes'
    AND JoinClientsWebsites.id_clients = ?
" ; "" ; "" ; Clients::id
)
Where it's possible, use the first table (the one after FROM) to filter results.
In FileMaker, it's faster to search by a field of the layout table rather than by a field of a related table, right?
It's basically the same thing.
 
Regards,
Iwao
  • Author

Awesome... that's much faster.  Operation seems to have dropped down to less than a second.  Thanks for your help!

Another thought: Since you are using FMS13, you could run the query server-side using Perform Script on Server, and then pass the result back as a script result. 

SQL queries are already always executed by FMS unless there is an open record in the target tables in the user's session so there would be no immediate benefit by using PSoS.  And more vulnerability (PSoS not responding,...)

 

One note of caution on the webviewer: you don't always have control about when it fires.  So it is generally better to collect the URL through script (event triggered if needed) and set the URL in a field on the record (or global field).  That way, whenever the web viewer decides to refresh itself it just reads from the field and does not re-fire the SQL query.

In FileMaker, it's faster to search by a field of the layout table rather than by a field of a related table, right?

 

 

Actually, if the related field is indexed, searching a related table is just as fast as searching locally. :-)

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.