Through the cargo build -r mission package out of the package, after starting, why the memory is so high, after debugging, is the reason for mysql library, I have any problems with the use of mysql library?
What actually is the problem here? You have VS Code using over three gigabytes of memory but highlight a process using only 40MB ? Which is nothing by comparison.
VSCode's features are so complete compared to VSCode, is it comparable? Is it normal for my rust code to take up so much memory on a single query? The same function, I write in golang, about the point of 5M or so of memory.
It is said that rust's performance is compared with c++, if the performance of such a small code is not as good as golang, how can it be compared with c++, so I wonder if I used it wrong
Measuring memory alocation is hard, and it's not as simple as "calling free(ptr) or drop(resource) gives back the memory to the OS". Modern memory allocators try to hold on already-allocated memory and cache as much of it as possible, to avoid having to issue expensive system calls upon every single allocation.
And even when releasing resources does actually release memory to the OS, it may still not be reported as "free" and it may not even show up in any metric.
Basically, the only thing you can be sure about is: if your program runs without touching swap space, then you had enough memory, otherwise you didn't. Anything else (e.g. quite frankly bullshit metrics shown by the task manager) is a lie and not to be taken seriously the least bit.
Your program is so small and trivial that it's not even worth benchmarking. Differences in e.g. the size of dynamically-allocated and "leaked" standard I/O buffers (which depends on the language runtime) can suggest a disproportionately large difference between such tiny programs that it's basically down in the noise.
Go write a large production service in Go and Rust and measure the difference using a real profiler (not Task Manager). Then you'll learn something useful. But not with a 50-line trivial program.
There are a few things here that probably makes your program use more memory than what you'd expect. First is the flavor of tokio runtime you're using, then the connector library you're using seems to setup a pool of db connectors by default. Probably other things, but I'm on my phone and I'm just giving hints for you to investigate.
The pool is a bunch of reusable TCP or Unix domain socket (or the Windows version of UDS) connections inside your program. The pool does not spin up mysql child processes or calls out to some mysql client process but handles the connections completely in the main process.
You say that the indicators of the task manager have no reference value, but I think this is also a kind of performance, I hope that the official or the big guys give more advice
Any memory allocator with remotely decent performance will not immediately release freed memory back to the OS. Instead they will keep it around for a while in case it is needed in the future. Only after a certain amount of time or if the OS itself signals that there is too little free memory, do memory allocators release memory back to the OS and thus reduce the memory usage shown in task manager. You need to use a memory profiler to get the actual amount of memory the program consumes. The difference between Rust and Go could possibly be explained by a difference in memory allocator used. Rust defaults to the system allocator, while Go ships with it's own memory allocator. Without using a memory profiler there is no way to know for sure that this is actually the reason.
I think we should insist again that you measure with a profiler, not the windows task manager. On windows I think you can set up Visual Studio (not VScode) to do that with Rust. You should Google that.