Good afternoon, dear colleagues.
There is a table with a bunch of records in which the field Subscriber presented in the form of a phone number and there is a mapping table of phone number to name(in field and FIO Subscriber). Salt in the fact that not all subscribers have refer name, in consequence of which definitely will drop exceptions(Exceptions) that I process and leave there just the phone number.
Retrieves from SQL like this:
SELECT TOP 100 Calls.ID Calls.DateTime Calls.Trunk Calls.Subscriber, Subscribers.FIO Calls.ExtNum, Calls.Duration, Calls.Direction, Calls.ExitCode FROM Calls LEFT OUTER JOIN Subscribers ON Calls.Subscriber = Subscribers.Subscriber ORDER BY ID DESC
rec = new CDRRecord();
rec.ID = reader.GetInt64(0);
rec.DateTime = reader.By the getdatetime(1);
rec.Trunk = reader.GetString(2);
//If the value of Subscribers.FIO is not Null, assigning it to the record
//if null - will be the Exception
rec.Subscriber = reader.GetString(4);
//then assign the value of recording Calls.Subscriber
rec.Subscriber = reader.GetString(3);
rec.ExternalNumber = reader.GetString(5);
rec.Duration = TimeSpan.FromTicks(reader.GetInt64(6));
rec.Direction = reader.GetString(7);
rec.ExitCode = reader.GetString(8);
This part works fine except for the fact that it is quite slow. If you do a sample of 100 records, then freezes for 1 second - not particularly critical, if 1000 can hang up to 5 seconds, and without the processing of the brakes will not, however, wish that there where there is information about the subscriber it was and where it should not show just the phone number.
The brake is inversely proportional to the amount of data in the table Subscribers, and that is logical — the more exceptions is invoked, the more brakes.
Please help or change the algorithm to avoid exceptions or to suggest how to avoid the brakes in this logic.
I understand that I'm doing something wrong, but that's where...
PS I tried to specify a specific exception in catch: