select statements
Hi everybody
It's been known that select statements are rather demanding from the server, so it's best not to use too many of them at the same time. I'm trying to streamline my database and was wondering if it makes a difference if the select statement refers to a different table rather than to a child table.
E.g.:
let varA := 'distance';
first((select 'Child')[miles = varA].bike)
Versus:
let varA := 'distance';
first(select 'Sister table'[miles = varA].bike)
If indeed it makes a difference, it would make sence to make this sister table a child instead of a sister.
Or maybe there is another way to retrieve the data from the child table which is even less demanding?
Thanks for your insights!
5 replies
-
You are correct that you should always try to limit the use of selects. If possible use the record() command or reference fields.
If you are looking into a child table and only want related records then you can skip the select and just use the reference field name (which by default is the table name).
If I have the following structure:
Table1 Child1 Table2
If I'm in Table1 I can always refer to the Child1 table with just:
Child1
So for your example it would be:
let varA := 'distance'; first(Child[miles = varA].bike))
This tells Ninox to use the reference field Child and then look at all of the linked records where miles = varA.
Your previous code:
let varA := 'distance'; first((select 'Child')[miles = varA].bike)
Will find all records in Child where miles equals varA regardless if it is related to the parent record.
I hope this helps.
-
indeed, this works better, Fred. Thanks!
Content aside
- 9 days agoLast active
- 5Replies
- 63Views
-
2
Following