I have a LINQ query which is searching a SQL table of around 250,000 records and only searching on 2 fields. Both fields have been indexed but I find its still running rather slow.
Below is the code, can anyone suggest anything to help speed it up?
thanks
var qryN = (
from bn in dbs.Uploads
orderby bn.ID descending
select new
{
ID = bn.ID,
Serial = bn.serial_no,
Manufacturer = bn.Mfgr,
Model = bn.model,
Code = bn.code,
Qty = bn.qty,
Description = bn.description,
Comments = bn.comments,
Location = bn.location,
Price = bn.price,
Email = "Register / Login for full details"
});
if (dlType.Text != " " && dlType.Text != "")
{
qryN = qryN.Where(bn => bn.Manufacturer == dlType.SelectedValue);
}
if (txtWord.Text != "")
{
qryN = qryN.Where(bn => bn.Description.Contains(txtWord.Text));
}
gvLoggedOff.DataSource =
from p in qryN
select new
{
p.ID,
p.Serial,
p.Manufacturer,
p.Model, p.Code,
p.Qty,
p.Description,
p.Comments,
p.Location,
p.Price,
p.Email
};
gvLoggedOff.DataBind(); var qryN = (
from bn in dbs.Uploads
orderby bn.ID descending
select new
{
ID = bn.ID,
Serial = bn.serial_no,
Manufacturer = bn.Mfgr,
Model = bn.model,
Code = bn.code,
Qty = bn.qty,
Description = bn.description,
Comments = bn.comments,
Location = bn.location,
Price = bn.price,
Email = "Register / Login for full details"
});
if (dlType.Text != " " && dlType.Text != "")
{
qryN = qryN.Where(bn => bn.Manufacturer == dlType.SelectedValue);
}
if (txtWord.Text != "")
{
qryN = qryN.Where(bn => bn.Description.Contains(txtWord.Text));
}
gvLoggedOff.DataSource =
from p in qryN
select new
{
p.ID,
p.Serial,
p.Manufacturer,
p.Model, p.Code,
p.Qty,
p.Description,
p.Comments,
p.Location,
p.Price,
p.Email
};
gvLoggedOff.DataBind();