Click here to Skip to main content
15,887,027 members
Home / Discussions / Database
   

Database

 
GeneralRe: copy of sql server database Pin
veereshIndia13-Jan-08 20:05
veereshIndia13-Jan-08 20:05 
GeneralRe: copy of sql server database Pin
veereshIndia13-Jan-08 20:30
veereshIndia13-Jan-08 20:30 
QuestionSQL Profiler for Sybase? Pin
devvvy7-Jan-08 23:29
devvvy7-Jan-08 23:29 
QuestionHow do I enumerate tables in a given database? Pin
devvvy7-Jan-08 18:57
devvvy7-Jan-08 18:57 
AnswerRe: How do I enumerate tables in a given database? Pin
Giorgi Dalakishvili7-Jan-08 19:23
mentorGiorgi Dalakishvili7-Jan-08 19:23 
QuestionLINQ and InsertOnSubmit Pin
TerryHam7-Jan-08 18:01
TerryHam7-Jan-08 18:01 
GeneralOptimizing Query - Order by inner joined value Pin
gnjunge7-Jan-08 4:09
gnjunge7-Jan-08 4:09 
GeneralRe: Optimizing Query - Order by inner joined value Pin
Michael Potter7-Jan-08 10:11
Michael Potter7-Jan-08 10:11 
COALESCE is built to handle numerous elements. You are only using two so ISNULL(Cities_Localized.[Name], Cities.[Name]) might be a bit faster (maybe not?).

I assume you already have an index on [Name] in both tables to handle the LIKE comparisons.

The next thing I would try is a temporary table so that the NULL testing is only done once. I am assuming you are using SQL server.
DECLARE @tmp TABLE
(
     CityName NVARCHAR(200)
)
  
INSERT INTO @tmp (CityName)
SELECT TOP 10 
    ISNULL(Cities_Localized.[Name], Cities.[Name])
FROM 
    Cities
LEFT JOIN 
    Cities_Localized 
    ON (Cities.CityID = Cities_Localized.CityID) AND 
       (Cities_Localized.Language  = 'en-US') 
WHERE 
    Cities.[Name] LIKE 'T%' OR 
    Cities_Localized.[Name] LIKE 'T%'
  
SELECT 
    CityName 
FROM
    @tmp
ORDER BY
    CityName

You can also try a UNION query and see if it is any faster.
SELECT 
    [Name] AS CityName
FROM
    Cities
WHERE 
    [Name] LIKE 'T%'
  
UNION 
  
SELECT 
    [Name]
FROM
    Cities_Localized 
WHERE
    Cities_Localized.Language  = 'en-US' AND
    Cities_Localized.[Name] LIKE 'T%'
  
ORDER BY
    CityName

If none of those resulted in a fast enough query, I would develop a table that contained all city names (normal and localized) with a Foreign Key back to the City table.
GeneralRe: Optimizing Query - Order by inner joined value Pin
gnjunge7-Jan-08 20:46
gnjunge7-Jan-08 20:46 
GeneralRe: Optimizing Query - Order by inner joined value Pin
andyharman8-Jan-08 0:25
professionalandyharman8-Jan-08 0:25 
GeneralRe: Optimizing Query - Order by inner joined value Pin
gnjunge8-Jan-08 1:59
gnjunge8-Jan-08 1:59 
GeneralRe: Optimizing Query - Order by inner joined value Pin
andyharman8-Jan-08 6:24
professionalandyharman8-Jan-08 6:24 
GeneralRe: Optimizing Query - Order by inner joined value Pin
gnjunge8-Jan-08 8:16
gnjunge8-Jan-08 8:16 
GeneralRe: Optimizing Query - Order by inner joined value Pin
andyharman9-Jan-08 2:45
professionalandyharman9-Jan-08 2:45 
GeneralRe: Optimizing Query - Order by inner joined value Pin
gnjunge9-Jan-08 7:11
gnjunge9-Jan-08 7:11 
GeneralStored Procedure Pin
simworld7-Jan-08 3:47
simworld7-Jan-08 3:47 
GeneralRe: Stored Procedure Pin
Colin Angus Mackay7-Jan-08 7:28
Colin Angus Mackay7-Jan-08 7:28 
GeneralRe: Stored Procedure Pin
simworld7-Jan-08 8:12
simworld7-Jan-08 8:12 
Questioninserting into SQL table with just a primary key column? Pin
michal.kreslik6-Jan-08 7:11
michal.kreslik6-Jan-08 7:11 
GeneralRe: inserting into SQL table with just a primary key column? Pin
Paul Conrad6-Jan-08 10:00
professionalPaul Conrad6-Jan-08 10:00 
GeneralRe: inserting into SQL table with just a primary key column? Pin
michal.kreslik6-Jan-08 21:07
michal.kreslik6-Jan-08 21:07 
GeneralRe: inserting into SQL table with just a primary key column? Pin
Pete O'Hanlon6-Jan-08 22:49
mvePete O'Hanlon6-Jan-08 22:49 
GeneralRe: inserting into SQL table with just a primary key column? Pin
Paul Conrad7-Jan-08 7:40
professionalPaul Conrad7-Jan-08 7:40 
GeneralRe: inserting into SQL table with just a primary key column? Pin
Chris Meech7-Jan-08 7:12
Chris Meech7-Jan-08 7:12 
GeneralRe: inserting into SQL table with just a primary key column? Pin
Paul Conrad7-Jan-08 7:44
professionalPaul Conrad7-Jan-08 7:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.