12
votes
4answers
389 views

Finding person with most medals in Olympics database

I have an Olympics database from each Olympic year and I want to find the person that has won the most medals. The main problem is that I'm basically querying the same sub-query twice in ...
6
votes
2answers
92 views

Put it in a bucket

You're running a jeans company. Your system is collecting detailed orders' data, but it's a bit archaic and it's storing the number of units ordered per size in a delimited string with 20 "fields", ...
8
votes
3answers
366 views
4
votes
1answer
36 views

Speeding up class that uses an ODBC connection

I have created a class that gets data from an ODBC connection. The code works but it is really slow - I'm talking up to 1.20ish minutes to run. I know my code is inefficient but I'm really not sure ...
7
votes
3answers
151 views

Getting the top 10 stores within a category

I have the following query. I know there's an easier way to do this without the sub queries, or at least optimizing how they're used. I've read about cross joins and using ...
5
votes
4answers
235 views

T-SQL statement to breakdown UserAgent information

I have a table that contains the UserAgent string and a Count of how many times its seen. The T-SQL below is used to give a ...
2
votes
1answer
67 views

UserDAO with CRUD functionality for my UserRepository

This is my first attempt at creating a DAO. I would like to get some feedback regarding the following aspects if possible: Code readability Efficiency Usability I also would appreciate any other ...
5
votes
1answer
58 views

How can I optimize this SQL ranking generator query?

I have a World Cup fixture app where people can guess the results of the matches. Everything is working great, but each time I update the ranking, it takes 20 minutes for just 3000 users. So there ...
5
votes
1answer
87 views

Optimize postgres function

This function code works very slowly. How can I speed it up? ...
4
votes
1answer
42 views

SEDE query to find users with exactly one post in a particular tag

I'm doing some research for a meta post on Gardening.SE (where I'm a pro tempore moderator). I'm using the Stack Exchange Data Explorer (SEDE) to find information about first time users who post ...
3
votes
4answers
3k 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: ...
2
votes
2answers
205 views

Speed up MySQL query with IN clause

I've tried to improve the speed of my query in MySQL, but when condition IN clause happens too often, the query runs very slowly. Can anyone help me optimize the ...
5
votes
2answers
53 views

SQL Query that pulls rows in current table based on parent id optimization

I am creating a user permission system. I will have my user permissions set up off of "objects" and not pages. For example, I have an EVENTS section. Within that ...
10
votes
2answers
120 views

Comparing client lists with Cross Joins

I've written a query to compare the clients in our database with the people in a list that I've received. It needs to check if anyone from the list is one of our clients. I've created a temporary ...
6
votes
1answer
68 views

Removing image records if no physical file exists

I have a working script that selects image fields in all tables and empty their values if the physical file doesnt exist. ...
3
votes
1answer
123 views

Querying a warehouse database

Consider the query given below: ...
3
votes
1answer
44 views

Check for similar value with SQL

I've two table (t1 and t2) with 3 identical integer columns : c1, c2 and c3. I want to count how many value in t1 are in t2 So I start to write : ...
3
votes
2answers
88 views

Adding a list of brokers to a local SQLite database

I have this piece of Java (Android) code that adds a list of brokers to a local SQLite database as one single SQL instruction. ...
-2
votes
3answers
111 views
3
votes
1answer
105 views

Query too slow - Optimization

I am having an issue with the following query returning results a bit too slow and I suspect I am missing something basic. My initial guess is the 'CASE' statement is taking too long to process its ...
2
votes
1answer
157 views

Correct use of my JOIN and arrays to fetch the data?

After learning a lot about programming, I've decided to write some code pertaining to scripting and use of different functions. I've come to a point where I'd like others to verify my code for ...
1
vote
2answers
66 views

Same records between two tables

I have the following tables: ...
3
votes
1answer
77 views

Slow MySQL query - 1200 rows in 5secs

Can anyone help me speed up this query? At present, it returns 1200 rows in 5 secs. I've notice that it is looking at 240000 response records. I think this is where the issue may be. I've created ...
6
votes
1answer
176 views

Help optimizing this query with multiple where exists

In the application I'm building, the user is able to define 'types' where each 'type' has a set of 'attributes'. The user is able to create instances of products by defining a value for each ...
1
vote
1answer
142 views

SQL with several joins

Is this query acceptable in terms of performance (I get the correct data) or can it be optimized? ...
2
votes
1answer
201 views

DAL Efficiency Help

I am attempting my first try at some c#. So far I love it, (not more than vb tho ;)) however, I am wondering if I can make these classes a bit more efficient. Please note ###Test is my attempts at ...
3
votes
3answers
3k 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 ...
2
votes
2answers
453 views

My simple CMS system - security and code obscurity?

I'm working on a simple CMS with the intent of making it as secure as possible (a personal challenge) and the code as clean as possible. I think I've a long way to go so I would appreciate any input, ...
0
votes
2answers
9k 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 ...
0
votes
1answer
179 views

Optimized MySQL query with complex calculation

I am trying to pick 3 providers with the highest calculated score based on my algorithm, to recommend them to a user. The recommendation algorithm takes into ...
1
vote
2answers
244 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? ...
2
votes
1answer
56 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 ...
2
votes
2answers
268 views

Subquery v/s inner join in sql server

I have following queries First one using inner join ...
3
votes
1answer
108 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 ...
7
votes
3answers
387 views
2
votes
1answer
57 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
39 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
135 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 ...
3
votes
2answers
909 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 ...
2
votes
1answer
267 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
1k 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? ...