optimization

Mysql Query Optimization

I have the following SQL query: select expr1, operator, expr2, count(*) as c from log_keyword_fulltext group by expr1, operator, expr2 order by c desc limit 2000; Problem: The count(*) as part of my order by is killing my application, probably because it don't use index. I would like to know if there is any way to make it faster, l...

VS2008 binary 3x times slower than VS2005?

I've just upgraded a native C++ project from VS2005-SP1 to VS2008-SP1 The first thing I tested was a very basic functionality test of the application and the first thing I noticed is that the main number-crunching algorithm performs three times slower in the VS2008 binary. I tested again the VS2005 binary to make sure there isn't any oth...

MSBuild maxcpucount > 1 Causes build errors

I'm trying to build about 600 projects some are .net 2.0, some are 3.5. I'm using Windows 2003 Enterprise Edition 32 bit with all the latest windows updates. Builds fine when maxcpucount is 1. If I bump it up to try and improve performance it get reference errors. When I look at the project references from where the error occurred it...

asp.net best practice string concatenation

I am trying to find the best practice for generating and outputting html which would require a database query first to obtain the info. Currently in the aspx page I have a div with runat server: <div runat="server" id="leaflet"></div> Now just as a start to do a bit of testing I have a method that runs on page_load that basically does...

PHP+MySQL: searching using wildcards

So, I have the following rows in the DB: 1 | /users/ 2 | /users/admin/ 3 | /users/admin/* 4 | /users/admin/mike/ 5 | /users/admin/steve/docs/ The input URL is /users/admin/steve/, and the goal is to find the URL match from the DB. I want to return #3 as the correct row, since the wildcard "*" specifies that anything can go in plac...

Limit Per Criteria

Hi, I have an articles table and a categories table. I want to fetch 7 articles for each category. Currently I have this but it's terrible slow on large tables so it's not really a solution: SELECT id, title, categories_id, body, DATE_FORMAT(pubdate, "%d/%m/%y %H:%i") as pubdate FROM articles AS t WH...

Temporary text attributes causing massive slowdown

I am using the code I posted as an answer to this question to display hidden characters in an NSTextView as bullets. I am coloring the bullets gray with the addTemporaryAttributes:forCharacterRange: method of NSLayoutManager. Each range is of length 1 and colors a single bullet. (Most of the same text I am using has relatively few adj...

mysql range index

Hi everybody, I have very simple select like this: SELECT * FROM table WHERE column1 IN (5, 20, 30); on column1 is seted index, after explaining query is index used, all looks to be ok. but if there are more than three values in range, like this: SELECT * FROM table WHERE column1 IN (5, 20, 30, 40); index is not used...

Forcing a UNION on an OR for optimization in SQL Server 2000

How can I get a query which uses an OR in the WHERE clause to split itself into two queries with a UNION during compilation? If I manually rewrite it, the query using the UNION is 100x faster than the single query, because it can effectively use different indices in each query of the union. Is there any way I can make the optimizer use...

What's the "average" requests per second for a production web application?

I have no frame of reference in terms of what's considered "fast"; I'd always wondered this but have never found a straight answer... ...

Taking a snapshot of optimized JVM runtime

I know that the JVM can do some pretty serious optimizations at runtime, especially in -server mode. Of course, it takes a little while for the JVM to settle down and reach peak performance. Is there any way to take a snapshot of those optimizations so they can be applied immediately the next time you run your app? "Hey JVM! Great job o...

Rolling and packing PHP scripts

I was just reading over this thread where the pros and cons of using include_once and require_once were being debated. From that discussion (particularly Ambush Commander's answer), I've taken away the fact(?) that any sort of include in PHP is inherently expensive, since it requires the processor to parse a new file into OP codes and so...

Programmatically combining images in PHP

I'm a big fan of Yahoo's recommendations for speeding up websites. One of the recommendations is to combine images where possible to cut down on size and the number of requests. However, I've noticed that while it can be easy to use CSS sprites for layouts, other image uses aren't as easily combined. The primary example I'm thinking of i...

Find the Minimum Positive Value

What's the best algorithm to find the smallest non zero positive value from a fixed number (in this case 3) of values or return 0 if there are no positive questions? My naive approach is below (in Delphi, but feel free to use whatever you like), but I think there's a more elegant way. value1Temp := MaxInt; value2Temp := MaxInt; value3T...

Does anybody have any experience with SSEPlus?

SSEPlus is an open source library from AMD for unified handling of SSE processor extensions. I'm considering to use this library for my next small project and would like to know, if anybody have experience with it? Can I use it on Intel machines? Any performance issues in comparison to direct SSE calls? Any issues on 64bit machines? Wha...

Time slicing in Oracle/SQL

Hello, I have a large-ish Oracle table containing rows representing units of work, with columns for start time and end time in addition to other meta-data. I need to generate usage graphs from this data, given some arbitrary filtering criteria and a reporting time period. E.g., show me a graph of all of Alice's jobs for the 24-hour pe...

How can I refactor this piece of Ruby code to remove duplication ?

Hi, I do not have problem as such but I am quite new to Ruby. I have the following 3 repeatable bits of code in one method and I would like to know how a true Rubyist would first of all remove the duplication and secondly make it more reusable. Here is the code in question: file = File.new( destination) doc = REXML::Document.new file...

Speeding up text output on Windows, for a console

We have an application that has one or more text console windows that all essentially represent serial ports (text input and output, character by character). These windows have turned into a major performance problem in the way they are currently code... we manage to spend a very significant chunk of time in them. The current code is ...

Django objects.filter, how "expensive" would this be?

I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database server. soknad_lis...

Code refactoring help - how to reorganize validations

We have a web application that takes user inputs or database lookups to form some operations against some physical resources. The design can be simply presented as following diagram: user input <=> model object <=> database storage validations are needed with request coming from user input but NOT when coming from database lookup hits ...