February 26, 2025 at 7:24 pm
I have had similar doubts about AI over past years... I don't see much that is that useful outside of some search result summaries.
However, over the recent month AI has been moving very rapidly with Grok3 and others. As I start to use AI more it is starting to become alarmingly impressive. With the exponential growth we will continue to see AI leap beyond what we have seen it capable of doing last month and the month before. Pay attention now because we are rapidly approaching the time when AI surpasses human intelligence and begins to improve itself autonomously which will bring mass disruption to our way of life on this planet for better or worse. These are certainly exciting times.
February 27, 2025 at 9:30 pm
I have started using CoPilot a lot lately, and I find it very useful for quickly writing the first draft for tasks like PowerShell scripting or creating an Extended Event trace.
Here is what I asked CoPilot this morning:
Please create a sample PowerShell script that does the following:
I have two strings, one called AesKeyBase64 and the other called AesInitVectorBase64
which need to be stored in a .json file and then read into variables of the same names.
Also, assume the .json file will be located in the same runtime folder as the script,
and terminate each line with a semicolon.
Here is what it gave me. It basically saved me about an hour of googling and initial development, and I like how it includes explanatory comments for each step.
Terminating each comment line with a semicolon is a bit quirky, but a follow-up request removed them.
<#
Here's a sample PowerShell script that stores the AesKeyBase64 and AesInitVectorBase64 strings in a JSON file and then reads them back into variables.
This script does the following:
Defines the AesKeyBase64 and AesInitVectorBase64 strings.
Stores these strings in a hashtable.
Converts the hashtable to JSON and saves it to a file.
Reads the JSON file and converts it back to a hashtable.
Assigns the values from the hashtable to the variables.
Outputs the variables to verify the values.
If you have any questions or need further assistance, let me know!
#>
# Define the strings;
$AesKeyBase64 = "YourAesKeyBase64String";
$AesInitVectorBase64 = "YourAesInitVectorBase64String";
# Create a hashtable to store the strings;
$data = @{
AesKeyBase64 = $AesKeyBase64;
AesInitVectorBase64 = $AesInitVectorBase64;
};
# Convert the hashtable to JSON and save it to a file in the same runtime folder;
$json = $data | ConvertTo-Json;
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path;
$jsonFilePath = Join-Path -Path $scriptDir -ChildPath "file.json";
Set-Content -Path $jsonFilePath -Value $json;
# Read the JSON file and convert it back to a hashtable;
$jsonContent = Get-Content -Path $jsonFilePath -Raw | ConvertFrom-Json;
# Assign the values to variables;
$AesKeyBase64 = $jsonContent.AesKeyBase64;
$AesInitVectorBase64 = $jsonContent.AesInitVectorBase64;
# Output the variables to verify;
Write-Output "AesKeyBase64: $AesKeyBase64";
Write-Output "AesInitVectorBase64: $AesInitVectorBase64";
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
February 27, 2025 at 9:44 pm
As they say in my part of the world (Gloucestershire) - that's the badger.
February 27, 2025 at 11:35 pm
If including some "AI features" into SSMS, I'd want to know how much slower and bloated is it going to make it? And as others have said, I'd definitely want the ability to turn the feature off.
I despise the fact that the Windows 10 updates are now installing Copilot onto all of my Windows 10 VMs that I use for testing. I obviously have absolutely no need for it there.
@edwardwill, your comment on using AI to write the Unit Tests for you is interesting. While I'm sure it can provide some basics, I seriously doubt it would help to catch the important stuff. Which, to me, then begs the question of why even bother in the first place.
As an example, I just asked Copilot to create a unit test for the following method:
private bool IsSha1Hash(string hash)
{
if (hash.Length != 40)
{
return false;
}
return hash.All(c => (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'));
}
It supplied the following test data:
[InlineData("0123456789ABCDEF0123456789ABCDEF01234567", true)] // Valid SHA-1 hash
[InlineData("0123456789ABCDEF0123456789ABCDEFX1234567", false)] // Invalid character 'X'
[InlineData("0123456789", false)] // Too short
[InlineData("", false)] // Empty string
But what happens if a null string is passed into my method!
February 28, 2025 at 8:00 am
@kevin77 - the short answer is that I use CoPilot to do the basic heavy lifting - I don't just tell it to write the unit tests and then assume that what it creates will suffice. So in your scenario, as I do in mine, I review what it has written and determine whether it's complete and appropriate. Moreover, your example was relatively trivial - in my line of work I'm creating and amending classes sometimes with multiple dependencies on repositories and services, almost all of which use the MediatR library and others. In this instance creating the unit test suites, which can sometimes run to hundreds of lines of code, with all the attendant mocking, is inexpressibly dull and so why wouldn't I use CoPilot? In the same way that, faced with hundreds of yards of corridor to sweep, I would use a vacuum cleaner rather than a dustpan and brush.
February 28, 2025 at 5:05 pm
Copilot, if I paste the XML for a query plan, can you give advice?
Copilot
Absolutely, I'd be happy to help analyze the XML for your query plan and provide advice!
Please go ahead and paste the XML content here.
I'll take a look and offer suggestions based on the details provided.
* * *
Wait Statistics
SOS_SCHEDULER_YIELD: 963 ms (239 counts)
MEMORY_ALLOCATION_EXT: 3 ms (1478 counts)
RESERVED_MEMORY_ALLOCATION_EXT: 2 ms (2075 counts)
Query Time Stats
CpuTime: 956 ms
ElapsedTime: 1915 ms
Observations
SOS_SCHEDULER_YIELD:
This indicates that the query is yielding the CPU to allow other tasks to run. High wait times here suggest CPU pressure or that the query is CPU-intensive.
Memory Allocation Waits:
Both MEMORY_ALLOCATION_EXT and RESERVED_MEMORY_ALLOCATION_EXT have high wait counts but low wait times. This suggests frequent memory allocation requests, which could be due to insufficient memory or inefficient query design.
Recommendations
Optimize CPU Usage:
Since SOS_SCHEDULER_YIELD is significant, consider optimizing the query to reduce CPU usage. This could involve indexing, query rewriting, or breaking down complex queries into simpler parts.
Memory Optimization:
Review the memory settings and ensure that the server has adequate memory. You might also want to look into optimizing the query to use memory more efficiently.
Indexing:
Ensure that the tables involved in the query have appropriate indexes. This can help reduce the CPU and memory load by speeding up data retrieval.
Parallelism:
The plan indicates DegreeOfParallelism="0" with NonParallelPlanReason="CouldNotGenerateValidParallelPlan".
Investigate why a parallel plan couldn't be generated and see if enabling parallelism could help.
Execution Plan Analysis:
Look at the execution plan to identify any expensive operations (e.g., scans, sorts) and optimize them. Consider adding or modifying indexes to improve performance.
If you have any specific parts of the query or execution plan you'd like to focus on, let me know!
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
February 28, 2025 at 5:25 pm
So, what do you think of the advice? Is it that much different than you'd get from a colleague? Likely it depends.
February 28, 2025 at 7:02 pm
So, what do you think of the advice? Is it that much different than you'd get from a colleague? Likely it depends.
Regarding asking CoPilot to analyze an execution plan, it's a good starting point and can draw attention to potential issues quickly. There are some important query level stats, like wait time by category and memory allocation that are not visible in the graphical plan, and are easy to overlook when spot checking XML by eye. But AI, if it's been trained for the task, misses nothing, even if it can't nail down a specific recommendation. I would say, yes, it's like a very efficient co-worker (more like a dedicated assistant) who is available 24x7 and is pretty good at what it does.
I hope that the new CoPilot feature in SSMS is especially trained on analyzing query plans. That would be even more helpful than T-SQL code completion. The version of CoPilot I used above is just what's included in my Office365 subscription.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
Viewing 8 posts - 16 through 22 (of 22 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy