optimization

Finding text content references in MySQL database.

Hi. There's a site containing dozens of text snippets, each of them may have links and I need to build connections between snippets. Snippets are stored in database, database layout is following: snippet: id primary key, title varchar(255), url varchar(400), body text references: snippet_id, crc32_sum backlinks: snippet_id, links_to p...

SQL Server: How can a table scan be so expensive on a tiny table?

Hi all I'm looking at an execution plan from a troublesome query. I can see that 45% of the plan is taken up doing a table scan on a table with seven (7) rows of data. I am about to put a clustered index to cover the columns in my query on a table with seven rows and it feels...wrong. How can this part of my query take up so much o...

Improving drawing performance on custom UIView

I have a custom UIView which is composed of many images, their positions are changing in response to the user touch. The view must track the user touch and i'm experiencing a performance bottleneck in the drawing of such view, preventing me to follow the input in realtime. At the beginning i was drawing everything in the [UIView drawRec...

linq foreach performance

Hi, I'm iterating over an anonymous type with about 1000 elements. The question here is how is it possible that my loop takes almost 3 seconds to complete while what inside the loops happens takes less than 1 ms. With a thousand elements i figure the loop must finish within the second, not 3. Is there a way to make it iterate faster? ...

Should a referencing column be restricted to a single table?

I'm working on a project, and we've been creating tables that store references as a combination of two columns. An example: we have an 'alerts' table, that is used to deliver information to the user. An alert can refer to a number of different things, you can be alerted about a new message, or if another user has mentioned you. Thes...

VB.net faster than C++?

Possible Duplicate: Why does C# execute Math.Sqrt() more slowly than VB.NET? I'm running into an interesting problem, wherein I have code in VB.net and the exact same code in C++. I'd expect C++ to naturally run a tad faster than VB.net, but instead I'm getting the exact opposite: VB.net runs more than twice as fast as C++. Th...

What's faster: new Vector.<T> OR Vector.<T>.splice(0, Vector.<T>.length)?

What gives the best performance? (edited to include another option) var myVec:Vector.<Number> = new Vector.<Number>(); for (...) // Do stuff - example: myVec.push(Math.random()); // Need to empty and repopulate vector myVec.splice(0, myVec.length); // OR myVec = new Vector.<Number>(); // OR myVec.length = 0; ...

serve required styles only CSS

Is there a way of filtering large CSS files for the only required selectors on a page, and creating css files that contain just these selectors? Case: I have a very large CSS file that I want to filter on a per page basis, so that the file size is cut down and can be cached by mobile devices. I was thinking along the lines of somethin...

Algorithm for filtering collection

I have object Country, which has Areas. Areas has Provinces. Provinces has Cities, and Cities, and Cities has hotels. I want to filter list of regions to have only objects with property userHaveBeenThere set to true(Areas,Provinces,Cities,and hotels. I'm going to bind this list to treeview. The worst part of this algorith situation, ...

index access by non-clustered index.

If I have two table of data. One has a clustered index CINDEX, the other is a heap HEAP. Both also have a non-clustered index on the same column - SEARCHCOL Assume my clustered index columns are the same size as a rowid and therefore the depth of both of the non-clustered index is the same. Which would take fewer I/O's to fetch a tabl...

Artificial Intelligence Compiler

I was wondering, is it possible to use Artificial Intelligence to make compilers better? Things I could imagine if it was possible - More specific error messages Improving compiler optimizations, so the compiler could actually understand what you're trying to do, and do it better If it is possible, are there any research projects...

MySQL - using String as Primary Key

I saw a similar post on Stack Overflow already, but wasn't quite satisfied. Let's say I offer a Web service. http://foo.com/SERVICEID SERVICEID is a unique String ID used to reference the service (base 64, lower/uppercase + numbers), similar to how URL shortener services generate ID's for a URL. I understand that there are inherent pe...

How to check which stored procedure is taking maximum time in sql server

I want to know what are various methods by which I can monitor which of my procedure, query is taking more time on various components(CPU cycle, scan time etc.) than already set threshold value. I want it to be logged as well. Whenever uses my site and calling some procedure. I want to make a log of all procedures crossing my threshold....

Fastest method for rendering a table view cell?

Hi, I'm developing an application that requires me to display many short strings of text in table cells. Currently, I'm using a default table view cell with about 14 UILabels added. Half of these labels contain static text that will not be changed, while the other half contains dynamic data that has to be updated when the table is scrol...

Return both JSON and HTML in AJAX call

Hi all, I have a few pages with an heavy javascript usage (e.g. sorting and filtering of a dataset). The typical usage is to display a list of complex items (usually rendered as <li> with some HTML inside): the user can delete, edit or add items with specific forms. Since the items are complex, I keep an array of javascript objects to ...

PSQL: select all assets that have all of given list of associated objects ids

Suppose we have a standard has and belongs to many association between products and categories product_categories table consists of product_id and category_id pairs. We have list of category_id's and need to select all products that belongs to all these categories. The best approach that came to my mind is to have multiple EXISTS() in ...

Problem with eager loading of nested models

Hi, I have some models - NewsArticle, Comment, User (as :author) and Profile. class NewsArticle < ActiveRecord::Base belongs_to :author, :class_name => "User", :foreign_key => "user_id" has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at', :include => 'translations' end class Comment < ActiveRecor...

In VB.NET, what data structure to use so that, given two characters, return an integer for optimum performance?

I am finishing up a program that does a large number of calculations and am trying to optimize the innermost loop. The calculation I am currently looking at iterates over a large number of pairs of words and makes a table of the counts of corresponding pairs of characters. For example, one pair of words might be: voice louse and the...

How can I delay the loading of CSS background images?

I am animating sprites in a HTML/JavaScript game by showing/hiding/repositioning many divs, each with a CSS background image. I'd like to load some of the images only when they are first needed, rather than loading them all when the page is first loaded. Will setting them all to "display:none" initially and then showing/hiding them wit...

Clojure Parallel Mapping and Infinite Sequences

Let's say I define the sequence of all natural numbers in the following way: (def naturals (iterate inc 0)) I also define a function mapping the naturals to nil that takes a while to compute like so: (defn hard-comp [_] (Thread/sleep 500)) Note the computation time to evaulate the following s-expressions as measured by clojure.core...