VSCode - SQL Server (msql) Extension - Prevent query execution on tab change - visual-studio-code

I am using the SQL Server (msql) extension in VSCode and really liking it.
However when I want to run 2 queries I am discovering that the results will refresh every time I switch result tabs.
Both results tabs are in the same well (seems to not happen when they are in different wells)
Can I prevent this from happening and retain the original query results?

"mssql.persistQueryResultTabs": true

Related

MySQL Workbench Results

How do disable the Result in workbench?
The reason I am asking is that after certain number of results displayed, MySQL pops up with a message "The maximum result is reached for results. Do you want to continue?" something along those line.
You don't disable results or result sets as these are the meat of any database client tool. A result is what you get when you query your database. Disabling that would mean you don't do anything meaningful anymore with the database.
The error you get, however, is shown because you got too many results to display. Each query, which returns a result set, creates a tab in the result area. Creating too many tabs no only makes no sense, since you cannot really see them, but also consumes a lot of system resources. So there's this sanity check in MySQL Workbench to avoid creating too many.
Solution: make sure your scripts/queries don't return more result sets than what you have set in your settings:
or increase that amount via preferences -> SQL Editor -> Query Editor -> Max number of result sets, but use a sane value there!

Out result directly onto current screen field without C# etc

Is there a way to output my SQL result directly to where screen cursor is currently. Example: If i execute "select 1" I want the result 1 to immediately populate where my cursor is (like a form fill). So if i place my cursor in an open notepad file, execute the query, it populates the 1 directly in as though "typed" in. I need to achieves this all through SQL query without C# or others.
Pretty sure many won't approve (if it's even possible) but i do have my reason for wanting to achieve this.
In short: no.
Long: I am sure you can't do this without using other programming languages.
The databases' purpose is to help application developers with storing and effectively retrieving data. So, it's kind of "utility for developers" which doesn't do anything useful without a separate (let's call it "front-end") program that inserts into and requests data from there.
My guess is you need a standalone program that wait for special key combination, asks db for data retrieval, detects active window and the element, and pastes data in there

Can I debug a PostgreSQL query sent from an external source, that I can't edit?

I see how to debug queries stored as Functions in the database. But my problem is with an external QGIS plugin that connects to my Postgres 10.4 via network and does a complex query and calculations, and stores the results back into PostGIS tables:
FOR r IN c LOOP
SELECT
(1 - ST_LineLocatePoint(path.geom, ST_Intersection(r.geom, path.geom))) * ST_Length(path.geom)
INTO
station
(continues ...)
When it errors, it just returns that line number as the failing location, but no clue where it was in the loop through hundreds of features. (And any features it has processed are not stored to the output tables when it fails.) I totally don't know enough about the plugin and about SQL to hack the external query, and I suspect if it was a reasonable task the plugin author would have included more revealing debug messages.
So is there some way I could use pgAdmin4 (or anything) from the server side to watch the query process? Even being able to see if it fails the first time through the loop or later would help immensely. Knowing the loop count at failure would point me to the exact problem feature. Being able to see "station" or "r.geom" would make it even easier.
Perfectly fine if the process is miserably slow or interferes with other queries, I'm the only user on this server.
This is not actually a way to watch the RiverGIS query in action, but it is the best I have found. It extracts the failing ST_Intersects() call from the RiverGIS code and runs it under your control, where you can display any clues you want.
When you're totally mystified where the RiverGIS problem might be, run this SQL query:
SELECT
xs."XsecID" AS "XsecID",
xs."ReachID" AS "ReachID",
xs."Station" AS "Station",
xs."RiverCode" AS "RiverCode",
xs."ReachCode" AS "ReachCode",
ST_Intersection(xs.geom, riv.geom) AS "Fraction"
FROM
"<your project name>"."StreamCenterlines" AS riv,
"<your project name>"."XSCutLines" AS xs
WHERE
ST_Intersects(xs.geom, riv.geom)
ORDER BY xs."ReachID" ASC, xs."Station" DESC
Obviously replace <your project name> with the QGIS project name.
Also works for the BankLines step if you replace "StreamCenterlines" with "BankLines". Probably could be adapted to other situations where ST_Intersects() fails without a clue.
You'll get a listing with shorter geometry strings for good cross sections and double-length strings for bad ones. Probably need to widen your display column a lot to see this.
Works for me in pgAdmn4, or in QGIS3 -> Database -> DB Manager -> (click the wrench icon). You could select only bad lines, but I find the background info helpful.

jQuery Auto Complete - Performance Issue

We are using the plugin https://goodies.pixabay.com/jquery/tag-editor/demo.html for our AutoComplete feature. We load the source with 3500 items. The performance gets too bad when the user starts typing and the autocomplete loads the filtered result after 6 to 8 seconds.
What are alternate approach that we can take for upto 4000 items for Autocomplete.
Appreciate your response!
are you using the minLength attribute from autocomplete?
on their homepage, they have something like this:
$('#my_textarea').tagEditor({ autocomplete: { 'source': '/url/', minLength: 3 } });
this effectively means, that the user has to enter at least 3 charaters before autocomplete will be used. doing so will usually reduce the amount of results from the autocomplete to a more sane count (like 20-30 maybe).
However, this might not necessarily be your problem. first you should figure out, if it's your server that's got a problem with responding fast (you can use your browser developer toolbar to see how long the requests takes to complete).
If the request takes 6-8 seconds, then you will have to optimize your server's code. On the other hand, if the response is quick, but tageditor needs a long time to build the suggestion list, then the problem is, that it might not be optimized for so many suggestions. in that case, the ultimate solution would be to rewrite the autocompletion module yourself or patch the existing one to better scale to your needs.
Do you go back to the server every time the user types in something to get the matching results?
I am using SPRING ehcache which gets all the items from database and stores in the server cache when the server is started. Whenever the user types the cached data is used which gets the results with few milliseconds. Some one else recommended me to use this.Below is the example for it
http://www.mkyong.com/ehcache/ehcache-hello-world-example/
I am using the jQuery autocomplete features with 2500 items without any issue.
here is the link where it being used http://www.all4sportsonline.com

SQl Developer Single Query result tab please

In the free application SQL-Developer (provided by Oracle), I tried searching around for this but couldn't immediately find a solution. I find the opening of multiple SQL query result window/tabs mildly annoying. I'm sure there are very useful cases for this feature, but my question is:
Can we turn the multiple query result windows to just one (Toad style). If there's a shortcut key for this, that would be super awesome.
SQL Developer 4.0 (2013)
Close all the Query Result tabs
Tools > Preferences
Database > Worksheet > uncheck "Show query results in new tabs"
So, it turns out this is a bug. If you look closely, you'll notice that for each query run, your results tab is automatically being pinned, causing each new query run to need it's own new tab to display the results.
The automatic pinning is only supposed to be enabled when you explicitly go into Tools->Preferences->Database->Worksheet->"Automatically Freeze Result Tabs".
It is an identified bug, that Oracle fixed with SQL Developer 2.1.1.
Go to oracle.com and download the latest version and this should go away. It was definitely very annoying.
Instead of "Run Statement" click on "Run Script"(F5). This would give the output of two queries in the same Query Result window.
Directly to the database or from an application? Do you mean returning one result set from multiple tables together or multiple result sets in one pane? Are you using SQL 2000, 2005, 2008, or something else? The question is vaguely worded, but I'll try to help anyway.
For the purposes of this answer, I think you're trying to query the database directly. Open SQL Server Management Studio 2005 or newer (Not sure if this works in 2000), click New Query, and type the multiple queries into the pane. i.e.:
select * from table1
select * from table2
will return two result sets in the same window/pane.
Unpin helps keep current tab for next query.
(I am using Oracle SQL Developer 22.x)
I found that this was happening in SQL Dev v4.0.2.15 because I was running 2 SELECT statements. Running one SELECT at a time re-used the Results tab.