I have a table of events, I need to find all tail events of type 1 and all head events of type 1.
So, for the set of events in this order [1, 1], 3, 1 ,4, 5, [1,1,1] the brackets denote head and tail events of type 1.
This is much better illustrated in SQL:
drop table #event
go
create table #event (group_id int, [date] datetime, [t...
We have a system that is concurrently inserted a large amount of data from multiple stations while also exposing a data querying interface. The schema looks something like this (sorry about the poor formatting):
[SyncTable]
SyncID
StationID
MeasuringTime
[DataTypeTable]
TypeID
TypeName
[DataTable]
SyncID
TypeID
DataC...
I'd like to gather metrics on specific routines of my code to see where I can best optimize. Let's take a simple example and say that I have a "Class" database with multiple "Students." Let's say the current code calls the database for every student instead of grabbing them all at once in a batch. I'd like to see how long each trip to th...
SELECT DISTINCT
'LRS-TECH 1' || rpad(code,7) || rpad('APPTYPE',30) ||
rpad(licensing_no,30) || rpad(' ',300) AS RECORD
FROM APPS
WHERE L_code = '1000' AND licensing_no IS NOT NULL
This seems to be the primary culprit in why I cannot export these records to a textfile in my development environment. Is there any way I can ge...
I used to do this:
SELECT layerID
FROM layers
WHERE ownerID = ?
AND collectionID = ?
Which would give me an array of layerID's, and then I'd loop and do this for each one:
SELECT DATA
FROM drawings
WHERE layerID = ?
And it all worked fine. So now I'm trying to do it in one step, so I try this:
SELECT DATA , layerID
FROM drawings
W...
For instance, would the compiler know to translate
string s = "test " + "this " +
"function";
to
string s = "test this function";
and thus avoid the performance hit with the string concatenation?
...
How to convert last 3 digits of number into 0
example 3444678 to 3444000
I can do like
(int)(3444678/1000) * 1000= 3444000
But division and multiplication could be costly...
Any other solution????
...
When I'm writing some tight loop that needs to work fast I am often bothered by thoughts about how the processor branch prediction is going to behave. For instance I try my best to avoid having an if statement in the most inner loop, especially one with a result which is not somewhat uniform (say evaluates to true or false randomly).
...
Similar to this question, but for VB.NET since I learned this is a language thing.
For instance, would the compiler know to translate
Dim s As String = "test " + "this " +
"function"
to
Dim s As String = "test this function"
and thus avoid the performance hit with the string concatenation?
...
How can I take full advantage of 64-bit architecture in my .NET 2.0 Web Applications and Console/Forms Applications?
...
I have seen a lot of ob_get_clean() the last while. Typically I have done $test .= 'test'
I'm wondering if one is faster and/or better than the other.
Here is the code using ob_get_clean():
ob_start();
foreach($items as $item) {
echo '<div>' . $item . '</div>';
}
$test = ob_get_clean();
Here is the code using $test .= 'test':
...
Can someone explain to me why I'm seeing the following behavior:
mysql> show index from history_historyentry;
+----------------------+------------+------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name ...
This follows on from this question where I was getting a few answers assuming I was using files for storing my HTML templates.
Before recently I've always saved 'compiled' templates as html files in a directory (above the root). My templates usually have two types of variable - 'static' variables which are not replaced on every usage bu...
Suppose I have an interval (a,b), and a number of subintervals {(ai,bi)}i whose union is all of (a,b). Is there an efficient way to choose a minimal-cardinality subset of these subintervals which still covers (a,b)?
...
On a site where 90% of the pages use the same libraries, should you just load the libraries all the time or only load them when needed? The other pages would be ajax or simple pages that don't have any real functionality.
Also, should you only load the code when needed? If part way down a page you need a library, should you load it then...
The application de-serializes a stream into dynamically allocated objects and then keeps base type pointers in a linked list (i.e. abstract factory). It's too slow. Profiling says all the time is spent in operator new.
Notes: The application already uses a custom memory allocator that does pooling. The compiler is VC++ 6.0 and the co...
I'm talking about this:
If we have the letter 'A' which is 77 in decimal and 4D in Hex.
I am looking for the fastest way to get D.
I thought about two ways:
Given x is a byte.
x << 4; x >> 4
x %= 16
Any other ways? Which one is faster?
Thanks.
...
I'm looking for the fastest way to determine if a long value is a perfect square (i.e. its square root is another integer). I've done it the easy way, by using the built-in Math.sqrt() function, but I'm wondering if there is a way to do it faster by restricting yourself to integer-only domain. Maintaining a lookup table is impratical (...
I hope we all know by now that Premature optimization is the root of all evil.
One side of that quote means by optimizing you are increasing complexity and complexity is evil. The other less known side is today's optimization might be meaningless tomorrow.
What I mean is we used to think that, "Floating-point operations are slow, ther...
Google app engine tells me to optimize this code. Anybody any ideas what I could do?
def index(request):
user = users.get_current_user()
return base.views.render('XXX.html',
dict(profiles=Profile.gql("").fetch(limit=100), user=user))
And later in the template I do:
{% for profile in profiles %}
<a href="/p...