Best practice - multiple server connects for different dB tables, or one server connect with a more complex dB query?

Hey all, just wondering what the best practice is for something like this, from both a stability but also performance perspective?

If I have 3 tables of data that need to be shown on a page - should I have 3 server connects, or should I have one server connect that attempts to get data from all 3 tables with reference links and a more complex query?

I don’t think there’s a single answer to this, it depends on your situation and what you’re looking to do.

One key question I ask myself when deciding each time is…

Will you want to refresh the output on the page for just one query or are you happy for everything to refresh if you do a ‘load’ app connect action?

This will help you decide whether to keep it in a single server connect file or not. Having in one file is very tidy and means only one app connect action to use it but I think you’ll miss out on being able to interact with them individually.

I created a dashboard for one of my projects and had all the stats in a single server connect file but I then wanted to refresh each box when data had changed but I could only load the main file again which refreshed everything so there was lots of unnecessary data processing.

I saw a post somewhere which hinted that being able to select a query from within a server connect file was being considered but I don’t know any more than that.

4 Likes

Thank you - this is a helpful way to look at it, much appreciated.

I can pretty much echo sitestreet's thoughts. It can be done either way. But it really depends on your usage on what may be better. If the data returned is small and you only have two or three queries you can likely get away with putting it in one Server Connect.

Personally, I keep them separate so I have more control when and where to use them. I also deal with filtering and reloading data from tables that have thousands of records. So no need to process that each time, just when needed.

But either way is acceptable. It's a matter of what works best for you.

2 Likes

Thank you @brad - appreciate the advice.

1 Like