Viewing 15 posts - 196 through 210 (of 1,396 total)
I don't know. Setting STATISTICS ON doesn't work on Fiddle
Simplified without the 4th CTE
declare @max_number int = 100;
declare @half_max_number int...
June 20, 2023 at 12:57 am
As one query
DECLARE @maxNumber INT = 1000;
WITH BitArray AS (
SELECT [value] AS Id, 1 AS Bit FROM generate_series(1, (@maxNumber - 1) / 2,...
June 19, 2023 at 11:37 pm
Aha the recursive CTE has been replaced with a 3rd usage of the GENERATE_SERIES function
-- Create a table to store the bit array
CREATE TABLE BitArray (
...
June 19, 2023 at 11:10 pm
More from ChatGPT-4
Now, let me explain how the Sieve CTE works and how it fits in with the rest of the query.
The Sieve of Eratosthenes algorithm works by iteratively marking...
June 19, 2023 at 10:59 pm
After giving it a few tries lately I've been trying to get GPT-4 to do things which wouldn't otherwise be attempted. So here is AI's implementation of the Sieve of...
June 19, 2023 at 9:39 pm
Ok the proof by induction is acceptable
If 2 doesn't add or subtract from what's being measured that's a good reason to get rid of it imo
For my projects the upgrade...
June 19, 2023 at 3:55 pm
including p.N%6 IN(1, 2) It does increase the performance a bit, so I would argue it is appropriate. It changes the number of prime candidates from n/2 (odd numbers)...
June 19, 2023 at 3:02 pm
Shifting gears, there's a slight enhancement to Steve's algorithm that reduces the execution time from 2 seconds to 1.8 seconds. This improvement involves testing whether the prime candidate is...
June 19, 2023 at 12:48 pm
That's the article which had shaped my low expectations. Good to know it's been improved. It's also interesting Jonathan used GENERATE_SERIES in place of the non-itvf method of TOP and...
June 17, 2023 at 11:49 am
These are great comparisons. The so-far winning code was jointly arrived at. Interesting in a straight comparison GENERATE_SERIES appears faster than fnTally
June 16, 2023 at 10:46 pm
At the moment I don't have access to an instance of SQL 2022 to test with. That could change in the near future tho. For now I was just fishing...
June 16, 2023 at 4:17 pm
Why mess with fnTally when what we really need is for Jeffrey to rewrite the query? Ha, then we also get a baseline of the functions. Also how does the...
June 16, 2023 at 2:40 pm
Each number you test for primality needs O(sqrt(n)*n) calculations, so it will slow down for larger numbers. Also, if you increase @n to 10 times its previous value each...
June 15, 2023 at 2:02 pm
You only need to test up to the square root of a number to test for primality, which is quite a saving:
declare @n ...
June 14, 2023 at 3:03 pm
Oh you're right. This is not the final version but I'm not finding my notes on this. Iirc if you follow the links it leads to a SQLlite script with...
June 14, 2023 at 1:22 pm
Viewing 15 posts - 196 through 210 (of 1,396 total)