diff options
| author | Kapil Viren Ahuja <k.v.ahuja@gmail.com> | 2017-02-21 14:09:09 +0530 |
|---|---|---|
| committer | Kapil Viren Ahuja <k.v.ahuja@gmail.com> | 2017-02-21 14:09:09 +0530 |
| commit | f96085e5b3ec8931cf6eb06c4b1dae3b82967340 (patch) | |
| tree | bf7dddbd7973ddf45019f5b376be9d1c558c863d | |
| parent | 00b2d5161941aa9dab130a50783b8bd66b4a3dd1 (diff) | |
| download | processor-f96085e5b3ec8931cf6eb06c4b1dae3b82967340.tar.gz processor-f96085e5b3ec8931cf6eb06c4b1dae3b82967340.zip | |
reference queries for updating roster with match's FK
| -rw-r--r-- | ref_queries/update_roster_match_relationship.sql | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ref_queries/update_roster_match_relationship.sql b/ref_queries/update_roster_match_relationship.sql new file mode 100644 index 0000000..a9c8cdc --- /dev/null +++ b/ref_queries/update_roster_match_relationship.sql @@ -0,0 +1,21 @@ +-- i am thinking how fast slow this will be and if we should do this in DB. +-- maybe we need a script to run a cursor and update records - dont know... +-- a few runs on 35K records was closing my server connection on my shitty laptop + +-- this will update all roster with match_apiId +update "roster" +set "match_apiId" = match."apiId" +from match +where (roster."apiId" = roster_1 or roster."apiId" = roster_2) + + +-- this is same as before however should only pick empty records +update "roster" +set "match_apiId" = match."apiId" +from match +where roster."match_apiId" is not null and (roster."apiId" = roster_1 or roster."apiId" = roster_2) + + + +-- this should always return a count of 2 for each match_apiId :) +select "match_apiId", count(*) from roster group by "match_apiId" |
