2
votes
1answer
45 views

Is there a more optimized way for this MySql Query

with below query i'm getting the results that i want but it's quite slow taking nearly 0.2 seconds (on an i5 machine). Is there a more optimized way to get the same results. Basically this query ...
1
vote
2answers
75 views

How to optimize this code?

So I have this piece of code in Java(Android) to add a list of brokers to a local SQLite database as one single sql instruction. public void Add(List<Broker> brokers) { if(brokers == null ...
2
votes
2answers
131 views

Subquery v/s inner join in sql server

I have following queries First one using inner join SELECT item_ID,item_Code,item_Name FROM [Pharmacy].[tblitemHdr] I INNER JOIN EMR.tblFavourites F ON I.item_ID=F.itemID WHERE F.doctorID = ...
3
votes
3answers
546 views

Optimize a Sql subquery containing multiple inner joins and aggregate functions

I have a select statement which is infact a subquery within a larger select statement built up programmatically. The problem is if I elect to include this subquery it acts as a bottle neck and the ...
7
votes
3answers
331 views

How to optimize this code to get a instant/better result instead of waiting at least 10 seconds every time?

I have the following code that unfortunately is really slow: private void FilterSessionByDate() { SessionsFilteredByDate = ...
3
votes
1answer
101 views

SQL view, better way?

I there a better way to write this query? I feel sure it can be done in one statement with joins, but I couldn't get it, and I'm afraid I've made it too slow. What suggestions do you have? I'm ...
2
votes
1answer
53 views

Is having preset queries prone for disaster?

Edit Just did some further reading around the website and have come to the conclusion that this method leads to Leaky Abstraction, sorry for wasting peoples time. Time to head back to the drawing ...
1
vote
1answer
33 views

SQL iteration-Insertion plus renaming

Base Info Two tables: tData, tData2 Exactly the same columns About 200,000 records SQL Server 2008 R2 Logic At first sight we need to insert tData rows into tData2. What else? We need a ...
6
votes
2answers
122 views

Has the following query been made in the optimum way?

SELECT p.name,m.name FROM parts p INNER JOIN Manufacturers m ON p.man_id=m.id ORDER BY p.name DESC If not, what should be done for its optimization? Here is the two tables: CREATE TABLE ...
3
votes
2answers
494 views

Which SQL statement is faster

My co-worker claims that using a parameterized Like statement is equivalent to dynamic sql and won't have its execution plan cached for reuse. He says that using sp_executesql will allow the execution ...
1
vote
2answers
188 views

How to optimize this SQL delete

I want to optimize the performance of this SQL query. If I populate this hashtable with one million keys the query will take around minute. How I can optimize this Java method for faster execution? ...
0
votes
2answers
4k views

Getting data from database and then outputing it to the DataGridView

I am at the point where I feel that I am not doing it right. It works and does the job, but I am sure that there are more efficient and smarter ways of doing it. I would like to see if there is a way ...
1
vote
1answer
247 views

Newsletter SQL query optimization

I want to build a small newsletter like tool which sends mails in pre-defined timespans. First after registration, second 14 days later, third 7 days later etc. I came across for two database designs ...
1
vote
1answer
408 views

How can I make this SQL Bit scalar function more efficient?

I'd like to make this SQL scalar function more efficient. How can I do that? CREATE FUNCTION [dbo].[fnFilterBySampleType] ( @context VARCHAR(10), @contextId INT, @sampleTypeId INT ) ...
3
votes
3answers
479 views

Inner join with first result

In SQL Server, there is two tables: Houses, and their images. I need a list with 20 houses with the first of their images (only one). I tried: SELECT top 20 h.id, h.name, im.id, im.name FROM ...

1 2
15 30 50 per page