Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:35:44+00:00 2026-06-04T18:35:44+00:00

I have a database in ms-sql-server express 2008 which is accessed with linq-to-sql from

  • 0

I have a database in ms-sql-server express 2008 which is accessed with linq-to-sql from the same pc.
(not much concurrent access, but complex queries)

It has several tables and each table can get quite big, to the point where performance of queries, deletes, updates and inserts becomes too slow.

There is one main table projects and almost every other table has

  • a direct 1-n relationship with a project
  • or an 1-n relationship with a table that has an 1-n relationship with a project,
  • or an 1-n relationship with one of these tables and so on.

Selects, deletes, updates and inserts always operate on a single project.
I never need to update entries across different projects or select matching items from 2 projects etc.

Is there some way I can use this fact to increase the performance of the database?

I already have a non-clustered index over the foreign key project_ID wherever applicable.

Is there anything else I can do?
Would partitioning help me, if it were available for sql-express?


edit:

examples of slow queries (paraphrased, most are linq-to-sql queries, for a few deletes i execute the sql directly):

  delete from items 
  where items.projectID=X 
  AND (items.prop1=a OR items.prop2=b OR items.prop3=c)
  (deletes a few 1000 items, fast when database is empty, slow when lots of other projects exist)

  select top 1 itemprops 
  from itemprops 
  inner join items on items.id = itemprops.itemid 
  inner join project on item.projectid=project.id 
  inner join modes on itemprops.modeId = mode.id
  where item.name = X and project.id = Y and mode.name = z
  (find a certain itemprop corresponding to an item and a mode)


  select top 1 * from foo where projectID=x and name=Y and type=z
  (nonclustered index on projectID + name + type exists)

The common point between all my queries is this: they all have a where projectID=XY in there somewhere

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:35:45+00:00Added an answer on June 4, 2026 at 6:35 pm

    All my attempts with indexes or various settings in the DB did not significantly improve performance.

    Here is what worked for me in the end:


    for this type of query:

     delete from items 
     where items.projectID=X 
     AND (items.prop1=a OR items.prop2=b OR items.prop3=c)
    

    Instead of bulk deleting all items matching the criteria, I found a way tht is significantly faster, using ON DELETE CASCADE

    1. create a new dummy project
    2. update all items that should be deleted:
      update items set items.projectID=DummyProjectID
      where items.projectID=X
      AND (items.prop1=a OR items.prop2=b OR items.prop3=c)
    3. delete the dummy project. Since cascade deletes were enabled, this also deleted the items.

    For some reason this is much faster than simply deleting the items. Creation of the new project and updating a few 1000 items happens almost instantly, and deleting the project is at least 10 times faster than deleting the items directly.


    For these types of queries:

     select top 1 itemprops ...
    

    it was much faster to load all itemprops for a project into a dictionary once, and then answer all queries from this local cache. It is not very elegant, and I have to remember to update the cache after each change, but it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database (SQL server express 2008) which has a column that is
First a little introduction. We have an SQL Server Express 2008 database, which schema
I have a simple database table (SQL Server 2008 R2 Express), which has a
I have strange scenario in which if I create database using SQL Server 2008
I have a database called MyDB in a Microsoft SQL Server 2008 Express instance
I have just installed VS C# Express 2008 which includes SQL Server Express 2008.
I have a database working in my local sql server 2005 express edition. I
I have a database on SQL Server 2008. I have an ASP.NET application that
A have a database on MS-SQL Server 2008 that is growing a lot, year
I have a table like this in my database (SQL Server 2008) ID Type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.