Which is faster/preferred: memset or for loop to zero out an array of doubles ?
double *d; int length=10; memset(d, length, 0); //or for (int i=length; i; i--) d[i]=0.0; ...
double *d; int length=10; memset(d, length, 0); //or for (int i=length; i; i--) d[i]=0.0; ...
I am trying to optimize a query that does something like this: SELECT ... CASE WHEN (condition) THEN (expensive function call #1) ELSE (expensive function call #2) END ... The query plan shows that for even in cases where 100% of rows satisfy the WHEN clause, a substantial portion of the time is spent in calls to the resu...
I'm reading up on indexes for optimizing database performance and would like to gather best practices for various database situations in terms of applying indexes. Take a totally non-indexed database with non-trivial amount of tables and rows, what rules do you use in determining what index is applied to what column of what type to achi...
Some days ago I started using partitioning to make it possible to work with large amount of data. I created master table as documentation suggest, created some child tables which inherit from the master one and then added a constraint for each child table to define the allowed key value. Constraint was like: CHECK (site_id = 'google.co...
I would like to test if a point is within a particular distance of a sphere. So you have these variables... Point3F spherePnt; F32 sphereRadius; Point3F testPnt; I could do... F32 dist = ( spherePnt - testPnt ).len() - sphereRadius; If dist is positive it is outside the radius, if dist is negative it is inside the radius. Or as a...
Hello, I've develop a Stored Procedure that gets data from the table VisitorsInfluences and builds five galaxies with the "most influenced visitors" at the middle of each one, and the visitors that are most influenced by them around them on each galaxy. Is this clear so far? I don't know why, the Stored Procedure is taking around 6 or ...
Hi guys, I've been reading a fair bit about the performance of using LINQ rather than using a for each loop and from what I understand using a LINQ query would be a little bit slower but generally worth it for convenience and expressiveness. However I am a bit confused about how much slower it is if you were to use the results of the q...
I have the following code that loads a user's Active Directory DirectoryEntry object from the user's SID: public static DirectoryEntry GetUserDirectoryEntry(SecurityIdentifier sid) { return new DirectoryEntry(string.Format("LDAP://<SID={0}>", sid.Value)); } Is there a more efficient way to do this? I'm having to optimize my code b...
Hi all, I'm running the following query on a Macbook Pro 2.53ghz with 4GB of Ram: SELECT c.id AS id, c.name AS name, c.parent_id AS parent_id, s.domain AS domain_name, s.domain_id AS domain_id, NULL AS stats FROM stats s LEFT JOIN stats_id_category sic ON s.id = sic.stats_id LEFT JOIN cate...
Hello, I'm trying to come up with a way to make the computer do some work for me. I'm using SIMD (SSE2 & SSE3) to calculate the cross product, and I was wondering if it could go any faster. Currently I have the following: const int maskShuffleCross1 = _MM_SHUFFLE(3,0,2,1); // y z x const int maskShuffleCross2 = _MM_SHUFFLE(3,1,0,2); //...
Hi, I'm trying to optimize my iPhone OpenGL ES app. This is based on the GLSprite and GLPaint sample apps. I've factored out EAGLView into a base class, and I'm subclassing it in 3 different OpenGL views to make 3 transparent layers. The display parent for the 3 EAGLViews is a UIView, and that UIView is a child of the UIWindow. I'm...
Hi, Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter = true) { if(tryUseGetter) { if(_properties[name]->hasGetter) { return (Type*)_properties[name]->getter(); } return (Type*)_properties[name]->data; } else { return (Type*)_properties[name]->data; } } ...
I'm designing a large scale web application with about 30 tables, more than 2/3 of which are related to each other. I'm using ASP.NET MVC, Linq to SQL with SQL Server 2008. These tables are meant to hold thousands of records. As a programmer, what should I focus on to help optimize the database and the queries to and from Linq? Do you...
Good day! There are a lot of questions how to store tags in DB here on stackoverflow, I finally decide to use Toxi approach (items table, tags table and many-to-many intermediate table) http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html I want to display a list of 20-50 tagged items on a page each with list of it's tag...
I need to store IP address in the most compact way possible, searching is not a concern. This also needs to be compatible on Windows, Linux, and Mac using any DB (MySQL, SQLite, Postgre, etc). Thanks to the ip2long() and long2ip() functions in PHP I can convert a IP4 address to a small int field rather than a varchar(15) or whatever. Th...
I've written an algorithm which calculates and stores all paths of a DAG, and it works nicely on small graphs - but now i'm looking to improve it's efficiency to run over larger graphs. The core logic of the algorithm is in createSF() and makePathList() below, the other methods are helpers - I can see that append is a bottleneck. Howeve...
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody tr') .filter(function() { var chkbox = $(this).find(':checkbox')[0]; return !chkbox.checked; }) .show(); on Button2 Click $('table.result_grid tbody tr') .filter(function() { var chkbox = $(this...
I need to show the number of results for a given category, and hide any categories that give no results. Example: This Yahoo!Jobs page shows the number of results in categories like City, Job Category, Experience etc. I work in C#/Asp.Net, and fear that our server will choke without some serious caching and sql optimization. How woul...
What are the most expensive (both in terms of bytecode and cpu cycles) statements in the Java Programming language? ...
In an environment where you have a relational database which handles all business transactions is it a good idea to utilise SimpleDB for all data queries to have faster and more lightweight search? So the master data storage would be a relational DB which is "replicated"/"transformed" into SimpleDB to provide very fast read only queries...