43,856 questions
0
votes
0
answers
43
views
Why isn't MySQL using appropriate indexes when available? When forced to use them, the performance difference is dramatic; is this normal?
I've got the following SELECT statement where all columns are properly indexed with the column they're joining on. I.e. all PKs & FKs have a corresponding, single-column index shown later ending ...
2
votes
1
answer
113
views
Combining 3 SQL queries
I am trying to combine 3 queries, but it doesn't work well. Separately they work very well.
It is about the following. I want to search for all games the user has participated in, user - '$POSTCharID'
...
1
vote
2
answers
112
views
Postgres inner join where and order by
Is there a way to efficiently order by a text field in a join query (i.e., fast on large datasets)? I understand that I probably need to filter the dataset somehow, to reduce the size of the dataset ...
0
votes
2
answers
95
views
Snowflake Join on a JSON field
I have 2 tables in Snowflake which contain a Json field, and I need to make a join based on this field. When this json has the same keys and values it means it equals. The problem is that I can't tell ...
0
votes
2
answers
85
views
Join based on jsonb from left which may represent any column in right?
I'm trying to create collections of movies through a join. The gist of the project is that new movies are added all the time and are tagged with certain qualities, so the collection would be updated ...
1
vote
1
answer
54
views
Retrieve from 4 SQL tables with two count/group by values?
I have 4 tables tblProducts, tblSellers, tblViewedtimes, tblContactedtimes with below columns. How can we retrieve summary as below:
tblContactedtimes
SellerId
CustomerID
ProductID
ContactedTime
2
...
-2
votes
1
answer
94
views
Creating a value array from a list with varying size
I have the need to create a function which takes an input list or numpy array and creates into a string. The issue is easy enough to compute when knowing the numbers and the particulars. Like in the ...
2
votes
1
answer
124
views
Allow query planner to eliminate a left join even when not joining on a unique key
A nice feature of SQL Server's query planner is that if you do not use any columns from a joined table, and the join does not affect the cardinality of the query, it can be eliminated altogether. You ...
0
votes
1
answer
24
views
Cannot resolve keyword 'mem_ev' into field in Django
I have a small Django project that consists of 2 models (Event, mem_ev) plus auth User and Profile such that Users --< mem_ev >-- Events (ie a classic many to many relationship between Users &...
1
vote
2
answers
147
views
Databricks dataframe join - ambiguous columns
I am facing a problem in my Databricks Delta Live Table (DLT) notebook. I am trying to join together two dataframes, of which one df is derived from the other, but I keep getting the following error:
&...
0
votes
1
answer
156
views
Join 2 tables based on row-specific time frames (crossing order information) KDB+/Q
I have two tables with order information, and am looking to find whether or not each order in one table has crossing potential with the other. Example tables:
t1:([]ric:`a`b`c;side:`buy`sell`buy;size:...
2
votes
5
answers
98
views
Group IDs from one table, then count groups having different values in another table
I have the following Postgres SQL tables:
db<>fiddle
create table t1(id,sval)as values
(88, 'X129de')
,(4, 'YHK33e')
,(44, '1K4892')
,(53, 'YHK33e')
,(42, 'YHK33e')
,(...
0
votes
2
answers
71
views
Selecting the Most Recent Assigned Queue for Each Agent with Current Status (Join)
SQL Query - Get the Most Recent Queue Assignment Before Agent Availability
I have two tables: Assignment and Status.
The Assignment table records when an AgentID was assigned to a queue (...
0
votes
1
answer
83
views
How to Fetch Chat Data Using Eloquent with Joins?
I'm trying to fetch chat-related data using Eloquent in Laravel 11 but I'm struggling to structure an optimized query using Eloquent relationships or joins.
I have two MySQL tables:
users -> id, ...
3
votes
2
answers
91
views
R data.table updating a table based on an inner join with another table
I need to update a subset of a table based on information in another table:
main_dt = data.table(ID = 1:3, flag=c(TRUE,TRUE,FALSE), treatment_id = c(1,2,1), total_cost = 0)
costs_dt = data.table(...
0
votes
0
answers
33
views
combine variable array of properties into a comma separated list powershell [duplicate]
I have a powershell command that pulls a list of devices with PRT in the name to a variable & am then trying to format the list in an easy to read output
$PrinterList = @(Get-WmiObject ...
1
vote
1
answer
58
views
Multiple left joins with different values from same column
I need help with SQL code that takes different values from the same column with each iteration and puts them in the same row without multiplying rows.
Example:
In table DECLARATIONS there is data ...
3
votes
1
answer
54
views
If concurrent queries insert records between loops of a nested loop join, can it affect the result of the nested loop join?
I was looking into the nested loop join of Postgres and its variations when I got a question.
For the default nested loop join, Postgres scans the inner relation every time for each tuple in the outer ...
1
vote
1
answer
190
views
Use CTE with JOIN to Update a Table in PostgreSQL
I attempted to use a Common Table Expression (CTE) to update a table in PostgreSQL with the following query:
WITH TMP AS (
INSERT INTO TABLE1 (...)
SELECT (...) FROM TABLE2
RETURNING *)
...
0
votes
1
answer
95
views
What is the quickest and most efficient way to combine two MYSQL queries into one JSON result [duplicate]
I know how to use basic SQL queries but need to know the best way to combine two queries.
For example, I can output users within a certain distance and it automatically adds a distance field. Ideally ...
1
vote
1
answer
68
views
Postgres SQL: Seeking way to returning all tags matched to media files
I asked an earlier question but kind of messed it up, so I'm reformulating it again here.
I have 3 related tables:
media
media_tags (bridge table)
tags
Here's the code I have so far:
SELECT m....
0
votes
0
answers
36
views
Join Large List of Dataframes in R [duplicate]
I have a list (final_dff3) of 448 dataframes like below:
head(final_dff3[[1]])
V2 V8
1 TNMD 0.0178
2 C1orf112 0.8201
3 STPG1 0.6201
4 CYP51A1 0.9435
6 WNT16 0.0282
7 HECW1 0....
0
votes
1
answer
66
views
Google Sheet formula for concatenation [duplicate]
Names
Value
Jack
A2
Jack
A3
Jack
A4
Tom
A5
Tom
A6
How can I join all values in "Value" column in one cell that map to each name in Column Names? Also, have another column that counts the ...
0
votes
2
answers
170
views
Polars faster alternative to successive joins
I have some big dataset and I need to do multiple successive joins that are slow. I figured an alternative was to unpivot the whole dataframe I was merging successfully, join once and then get the ...
0
votes
1
answer
150
views
How can I use PostgreSQL's EXPLAIN and ANALYZE to identify slow joins in a query? [closed]
I’m working on a PostgreSQL database with multiple tables, each containing millions of rows. Some of my queries with multiple joins are running slower than expected, and I want to identify the root ...