Note that there are some explanatory texts on larger screens.

plurals
  1. POSqlDataReader indexer performance
    primarykey
    data
    text
    <p>I have some code like this:</p> <pre><code>using (var cmd = TransicsCommand.GetFleetCommand()) { cmd.CommandText = @" SELECT dr.DeviceId, dr.DeviceTruckRelationId, dr.TruckId, dr.RelationCreatedOn, dl.DriverLoginId, dl.DriverId, dl.UserType, dl.LoginType, dl.SecondsSince DriverLoginCreated, Action.ActionId, Action.ActionTimestamp, Action.UserType actionusertype, Action.TripreportId, DeviceHeaderData.DeviceHeaderid, DeviceHeaderData.Odo, DeviceHeaderData.X, DeviceHeaderData.Y, DeviceHeaderData.ValidPosition, DeviceHeaderData.Tfu, DeviceHeaderData.FuelPercentage, DeviceHeaderData.Speed, InstructionsetAction.VersionId, tc.CouplingId, tc.TrailerId, tc.CouplingEvent, tc.TrailerEntry, tc.SecondsSince FROM TripReport.Action Action INNER JOIN DeviceHeader.Data DeviceHeaderData ON Action.DeviceHeaderId = DeviceHeaderData.DeviceHeaderId INNER JOIN Instructionset.Action InstructionsetAction ON InstructionsetAction.ActionId = Action.ActionId INNER JOIN DeviceHeader.Truck dht ON Action.DeviceHeaderId = dht.DeviceHeaderId INNER JOIN Device.TruckRelation dr ON dht.DeviceRelationId = dr.DeviceTruckRelationId LEFT OUTER JOIN [DeviceHeader].[LoginSession] dhls ON dhls.DeviceHeaderId = dht.DeviceHeaderId LEFT OUTER JOIN [LogIn].DriverLogin as dl ON dhls.DriverLoginId = dl.DriverLoginId LEFT OUTER JOIN [DeviceHeader].[TrailerCoupling] dhtc ON dhtc.DeviceHeaderId = dht.DeviceHeaderId LEFT OUTER JOIN [Trailer].[Coupling] as tc ON dhtc.CouplingId = tc.CouplingId "; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { Stopwatch sw = new Stopwatch(); sw.Start(); var trailerId = reader["TrailerId"]; sw.Stop(); Debug.WriteLine(trailerId + "-" + sw.ElapsedMilliseconds);//10s - 8s -... } } } </code></pre> <p>This code takes 40s. After searching a bit, I found out that the rule <strong>reader["TrailerId"]</strong> takes up 39s in total, the query itself runs very fast!</p> <p>Removing the "TC." header from "TrailerId" makes it run in 0.6s, the reader["TrailerId"] now only takes 0ms:</p> <pre><code>SELECT ..., tc.CouplingId, TrailerId,... </code></pre> <p>Is this a bug in the sqldatareader indexer code? I can't make sense of why the second version works so much faster than the first one.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload