How to optimize this linq query?
I have the following linq query: var allnews = from a in db.News where !(from c in db.NewsViews where c.UserGuid == thisUser.UserGuid select c.NewsGuid).Contains(a.NewsGuid) orderby a.Date descending ...
I have the following linq query: var allnews = from a in db.News where !(from c in db.NewsViews where c.UserGuid == thisUser.UserGuid select c.NewsGuid).Contains(a.NewsGuid) orderby a.Date descending ...
This optimzation question has been bugging me for the last day. In my program (a simple roguelike game), I use bitwise flags to store the attributes of map objects, such as if they are solid, or if they are rendered. However, I could accomplish the thing using polymorphism to return the appropriate value. My question is, is either way...
So I'm wondering how browsers treat requests for images. I'm hoping to use a cdn for serving product images on my website. I'd also like to use the cdn for serving button images and images used in my css. The problem with this is that I don't have control over the expires headers (Rackspace files is what I'm looking into). See, say I h...
I need to build and print a deeplink to any given comment. So that the user can directly access the specific comment with just clicking a link. I could not find a native drupal function to get this so i build it my own. My solution <?php global $base_url; $base = drupal_lookup_path('alias',"node/".$node->nid); $path = $base...
Say I have a loop like for (Foo aType : bar.getAList()) { if (aType.getBaz().equals(baz)) { return aType; } } bar.getAList() is called on each iteration of the loop. Does the JVM/compiler keep track of the fact that this is the same object, or does it naively call the method and create a reference to the List each time? A...
In an algorithm I have to calculate the 75th percentile of a data set whenever I add a value. Right now I am doing this: Get value x Insert x in an already sorted array at the back swap x down until the array is sorted Read the element at position array[array.size * 3/4] Point 3 is O(n), and the rest is O(1), but this is still quite ...
I'm working on a codebase with a lot of non-OO function libraries, and personally, I don't love php's java-inspired OO model. Unfortunately, I'm trying to solve the problem of the overhead that you get with a lot of included libraries, and see a lot of recommendation for autoloading. Which only works with classes. Is there any way to ...
My WCF server exposes database access remotely and ensures authentication. Typically, users download and upload large documents. The remote connection turns out to be quite slow. Are there any tips and tricks for optimizing the service to handle those types of communication effectively? ...
I am now trying to optimize the launch time of an application, and currently want to reduce the time spent by the OS image loader. From dyld(1), I found two environment variables: DYLD_PRINT_STATISTICS and DYLD_PRINT_INITIALIZERS. DYLD_PRINT_STATISTICS causes dyld to print statistics about how dyld spent its time. This is its output wh...
My program often deals with large quantities of data, and one particular component of it creates a subset of that data, based on a condition. You could view this as, having the string, 10457038005502 the problem is to return the first five (say) non-0 elements, that is to return: 14573 In actual fact, each element of this string i...
I need to get records count of table «posts» where votes>=5 to create pagination. tables: table «posts»: user_id, post_n, visibility, type visibility values: 0, 1, 2; type values: 'text', 'photo' … (it`s enum field, have 6 values) table «votes»: vote_n, post_n, voter_id, vote vote values: -1 or 1 query: SELECT post_n, (SELECT SUM...
I need to do some matrix operations on my computer. These matrices are large 1000000x1000000 and more, some operations requiring TB of memory. Obviously these cannot be directly loaded into memory and computed. What approaches can I use to solve these matrices on my computer? Assuming that the matrices cannot be reduced further using mat...
[This was initially on matrices, but I guess it applies to any variable generically] Say we have Var1 * Var2 * Var3 * Var4. One of them sporadically changes, which one of them is random. Is it possible to minimize multiplications? If I do In case Var1 changes: newVar1 * savedVar2Var3Var4 I noticed that then I need to recalculate ...
I have a view where if I select like this: select * from view where date = '17-sep-10' it returns in seconds. If I use a dynamic date: select * from view where date = to_date((select current_business_date from v_business_day), 'mm/dd/yyyy') it returns in 20 mins. Why would har...
Hi All, PageSpeed and Yslow suggest that to combine javascripts file to reduce HTTPRequest. But this is becuase (I think) pre ie8 browser has no more than 2 serverhost connection. But nowaday, browser has 6 serverhost connections, which means it has download javascripts in parrallel. So let say we have 1MB of javascript, should we brea...
I am working on an application which does sequentially write a large file (and does not read at all), and I would like to use posix_fadvise() to optimize the filesystem behavior. The function description in the manpage suggests that the most appropriate strategy would be POSIX_FADV_SEQUENTIAL. However, the Linux implementation descripti...
If I have something like this: class Post < ActiveRecord::Base has_many :comments, :as => :commentable do def approved find(:all, :conditions => {:approved => true}) end end end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true end ...when I do this, I get 2 hits to the database (not...
I am trying to use R to estimate a multinomial logit model with a manual specification. I have found a few packages that allow you to estimate MNL models here or here. I've found some other writings on "rolling" your own MLE function here. However, from my digging around - all of these functions and packages rely on the internal optim...
This question came at the right time, as I'm struggling with optimization as well. I am aware of the different "normal" optimization routines in R, and I am aware of parallel packages like snow, snowfall, Rmpi and the likes. Yet, I didn't manage to get an optimization running in parallel on my computer. Some toy code to illustrate : f...
I have a set of inequalities ( the mathematical question is expressed at math.stackexchange), and I am looking at the appropriate matlab toolbox that can do it. Is there a toolbox in Matlab that finds the range of x, given that y(x) is subjected to an inequality? But since I'm not exactly sure what is the name of this problem, therefor...