1

I'm wondering about how the create entity selection command in the 4D database works. Does that command also re-query data store internally to get entity selection? If yes then which one would be faster to retrieve entity selection from an existing classic 4D records selection? Use-case is I was trying to create a method with a parameter of table primary id and with that id I query data store to get entity selection from an existing classic record selection primary field. So I wondered which one would be optimized whether using an primary field as an argument for a method or an entity selection as an argument for that method. Any view on this would really be helpful. Thanks.

Ravi
  • 31
  • 5

1 Answers1

0

There are actually three questions here.

  1. how CREATE ENTITY SELECTION works. The docs are helpful. You simply pass the classic table name and an entity selection is returned.

  2. it does make a new request to the server for the entity selection.

  3. which is flat out faster is not really relevant because the real issue will be what you do with it and what kind of data is stored in each of the records.

If you use the old style QUERY command the entire result of the query along with all the contents of all the records are returned to you. If the records have lots and lots of fields or some large fields (BLOBs or pictures) that can be slow and create a lot of network traffic.

If you use the new dataClass.query() 4D returns an entity selection of the data which is a reference to the data instead of the data itself. Further, when the results are large or contain large fields that data isn't transmitted until specifically requested. So if you are searching a table of images, let's say, you can search on the title and get an entity selection but until you actually do something with the image itself it isn't sent.

4D has undergone a significant update in the last few years. It essentially has two languages now. The 'classic' language is the one you probably see if you've been given some old database to keep working. The 'new' language is called ORDA and is object based. 'Classic 4D' is familiar to 4D devs who have used it for 20+ years. ORDA is more familiar to folks with modern coding experience. It is also where all the attention to new development is being concentrated.

The strong commitment in 4D to supporting old databases means these two can exist concurrently in a single project. However, injecting ORDA into classic code is often a painful experience if you aren't familiar with both because in classic you are shuffling around the actual data (in terms of records) while in ORDA you deal with references to the data.

kirkBrooks
  • 91
  • 5
  • Hi Kirk, thanks for the info. Actually I was expecting to get answer of which one would be more efficient in case of passing an argument for a method where I can do something with the entity selection inside that method. Sorry I think my question might not be well structured here. – Ravi Apr 25 '22 at 07:21
  • Here's a thing I was wondering for. I have a method called `method1` which inside it plays with an entity selection. Now I wanted to know which way would be more efficient (or perhaps more faster approach) to pass an argument for that method where I can use the entity selection based on the argument passed in that method. 1. passing an entity selection by using `$obEntitySelection:=create entity selection([table])` first and then `method1($obEntitySelection)` 2. passing a primary field id value like `method1([table]ID)` and do a ds.table.get($tID)` to get entity selection – Ravi Apr 25 '22 at 07:22