Skip to main content
Solved

Adding index to existing table that isn't mine.


Forum|alt.badge.img+6

What’s the best way to add an index to an existing table that’s a third-party table?

It’s a table with an auto-increment field as it’s primary key (along with CompanyID). But when I look at the underlying views, the code is querying the table using non-indexed fields. I don’t have time, at the moment, to reach out to the third-party to suggest that they add a key to make the lookups faster mostly because I won’t have time to integrate any patch from them into my code base at this point even if they agree.

So I was thinking of adding a non-unique key on the fields that I see the view using.

Should I just add a SQL script to my customization project to add the index if it isn’t already in place?

Or is there a more official way that I should do this?

Best answer by Tony Lanzer

@Django, I would suggest a SQL script to add the index, yes, especially if this is a SaaS instance.  Is a unique index not possible for what it’s searching on?  In addition, I always write my customization SQL scripts to work when run multiple times.  As you mention, check if the index already exists before creating it.

View original
Did this topic help you find an answer to your question?

2 replies

Tony Lanzer
Semi-Pro I
Forum|alt.badge.img+1
  • Semi-Pro I
  • 75 replies
  • Answer
  • August 26, 2023

@Django, I would suggest a SQL script to add the index, yes, especially if this is a SaaS instance.  Is a unique index not possible for what it’s searching on?  In addition, I always write my customization SQL scripts to work when run multiple times.  As you mention, check if the index already exists before creating it.


Forum|alt.badge.img+6
  • Author
  • Captain II
  • 560 replies
  • August 26, 2023

The table is kind of a register table that also has the current state of a piece of equipment that I can reliably count on. So we’ll have multiple records with the same equipment ID but only a handful per sales order so I can take the ‘hit’ on having to look at a half-dozen records knowing the sales order number.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings