Subject performance on calculated fields - performance question
Author

Hello! I have a customers table. I created some calculated fields in order to have the complete name of each customer in a single column. I attach the field definitions below. I don't know whether my calculated fields are "complex" or not to Firebird!


I'm testing with aprox 40.000 rows


select * from customers where company containing 'something'


Prepare time = 0ms

Execute time = 93ms

Avg fetch time = 23.25 ms


or...


select * from customers where name_company containing 'something'


Prepare time = 15ms

Execute time = 281ms

Avg fetch time = 56.20 ms


With 40.000 records, I have no problem with this. But do you think it will be very bad as the customers keep growing?

I mean, generally speaking, it's "expensive" (regarding to the speed) to have calculated fields??

Thanks!


---


create table customers (


    first_name   varchar(50),

    second_name  varchar(50),


    name       computed by (

                   coalesce(first_name,'') || ' ' ||

                   coalesce(second_name,'')),


    company      varchar(50),


    name_company       computed by (

       trim(name ||

       iif((company <> '')and

           (name <> company)and

           (name <> ''),', ','') ||

           iif((name<>company),company,''))),