optimization

mysql subselect alternative

Hi, Lets say I am analyzing how high school sports records affect school attendance. So I have a table in which each row corresponds to a high school basketball game. Each game has an away team id and a home team id (FK to another "team table") and a home score and an away score and a date. I am writing a query that matches attendan...

Does Perl perform common subexpression elimination?

Hi, I wonder if Perl performs common subexpression elimination? And what kind of optimisations are done? ...

What will be faster among SQL Query many times or getting all once in List and process in loop

I have to process almost 300 records of data with records at a time. I want to know which option would be better. Get all 300 records at a time in a custom object, for example, in C# and process them by in a set of three records based on some key. OR Get 3 records every time from database and do some processing, then fetch next 3 recor...

XPath/XSLT Optimization ?

Hey, I'm basically taking fileA.xml, grabbing nodes from totally distinct parts of the file, and building a new tree in fileB.xml. Relative paths are a bit confusing now because once I get to a node nested 3 down, and I need to add another node which is nested 4 down from a totally different branch, I start needing global xpaths. Ques...

Is there a way to optimise this program in Haskell?

Hi I am doing project euler question 224. And whipped up this list comprehension in Haskell: prob39 = length [ d | d <- [1..75000000], c <- [1..37500000], b <-[1..c], a <- [1..b], a+b+c == d, a^2 + b^2 == (c^2 -1)] I compiled it with GHC and it has been running with above average kernel priority for over an hour without returning a re...

Common performance pitfalls on Android?

What are the most easy mistakes to make that can be performance sinks on Android? The documentation mentions "some floating point operations" can be "on the order of milliseconds" - has someone tested this? For the sake of discussion, let's assume its running on a G1/similar device. ...

Any sites which help write more optimal Ruby code?

I've just started writing Ruby code from a C++ background. When I write the code, I find myself writing C++ code using the Ruby keywords(using while and for loops when a single Ruby command will make the code much shorter). Are there any sites which you use where people can look at code and recommend more optimal ways to use the langua...

iPhone dev - NSTimer accuracy for time instead of recalculating?

I have a little project that is a timer that counts down 'til midnight, and I was wondering If I should leave it as it is, calculating the time until midnight each second (inside NSTimer method that gets called every 1 second): NSDate *now = [[NSDate alloc] init]; NSDateComponents *dateComponents = [[self gregorian] components: (NS...

How to optimize my SQL in server?

I would like to know how to optimize the following SQL to let my server load faster and take low usage? I need to calculate the radius distance for a US ZIP Code to get the result, such as 50 miles from a particular ZIP Code ( using latitude and longitude to calculate ) and to getting how many other data ( e.g. others ZIP Code ) from my...

Algorithm Optimization - Shortest Route Between Multiple Points

Problem: I have a large collection of points. Each of these points has a list with references to other points with the distance between them already calculated and stored. I need to determine the shortest route that begins from an origin and passes through a specific number of points to any destination. Ex: I'm on vacation and I'm st...

What's the fastest way to get the Constructor of an Object in AS3?

Which of these 3 is the fastest (least CPU cycles) on the AVM2 in ActionScript 3? Object(instance).constructor (instance as Object).constructor instance["constructor"] I would do some tests, but I have no idea how to accurately profile that kind of thing. ...

What is the optimization level ( g++ ) you use while compairing two different algorithms written in C++ ?

I have two algorithms written in C++. As far as I know, it is conventional to compile with -O0 -NDEBUG (g++) while comparing the performance of two algorithms(asymptomatically they are same). But I think the optimization level is unfair to one of them, because it uses STL in every case. The program which uses plain array outperforms the...

database index and memory usage

suppose I have a table that stores 100 million records of strings of varying sizes up to 20 characters in a column field. I need to index this column, I only have a 2GB-Ram machine, is this sufficient to perform such task? Is mysql recommended db engine for storage? ...

Quick Java Optimization Question

Will the Eclipse compiler automatically convert multiplication by a power of two into a bit shift, or should I do that manually? Thanks for the help. ...

How to find performance bottlenecks in C++ code

I have a server application written in C++ and deployed in Cent OS. I haven't wrote any part of its code but i need to optimize its performance. Its current performance is acceptable for few amount of users but when the number of users increase the server's performance decrease dramatically. Are there any tools, techniques or best pract...

In managed code, how do I achieve good locality of reference?

Since RAM seems to be the new disk, and since that statement also means that access to memory is now considered slow similarly to how disk access has always been, I do want to maximize locality of reference in memory for high performance applications. For example, in a sorted index, I want adjacent values to be close (unlike say, in a ha...

MySQL Prepared Statements vs Stored Procedures Performance

Hi there, I have an old MySQL 4.1 database with a table that has a few millions rows and an old Java application that connects to this database and returns several thousand rows from this this table on a frequent basis via a simple SQL query (i.e. SELECT * FROM people WHERE first_name = 'Bob'. I think the Java application uses client si...

RENAME faster than DROP+ADD in MySQL alter table

I'm performing some MySQL table maintenance that will mean removing some redundant columns and adding some new ones. Some of the columns to drop are of the same type as ones to add. Would the procedure be faster if I took advantage of this and reused some of the existing columns? My rationale is that changing column names should be a s...

C# code optimization for accessing datatable records

Hi, i have a cost issue with datatable. And i need to replace the code with a smarter one. i have a datatable and the sample values are like this: Columns : id, user_id, starttime, endtime Row Sample : 1 , 5, 05.10.2009 08:00:00,05.10.2009 17:00 my pseudo code is function something() { for(int i=0;i<datatable.Rows...

C# performance question

quandry is - which of the following two method performs best Goal - get an object of type Wrapper ( defined below ) criteria - speed over storage no. of records - about 1000- about 2000, max about 6K Choices - Create Object on the fly or do a lookup from a dictionary Execution speed - called x times per second NB - i need to deliver t...