« first day (1566 days earlier)      last day (2752 days later) » 

7:45 AM
morning
1 message moved to friendly bin
1 message moved to friendly bin
1 message moved to friendly bin
@Shaneis basic mod -> click "room > move messages" then select the messages you want to move, and enter the name of the target room.
I use Friendly bin to move message
we can do that for not formatted sql code
 
8:20 AM
Morning @AndyK, sounds like a plan
 
yep
 
8:47 AM
hello shaneis.
 
hey @ARr0w
 
you're message : @ARr0w 1 or 3 on the tests I've done...i have it in my head as "store only part of me" :)

i didn't get it.
 
yeah, sorry not the clearest
if you don't declare the length of a varchar variable you run the risk that only part of the information you are trying to store will get stored
the other part will get cut off and lost
 
ohky
thanks bro. There are some more things i am willing to learn, but from you.
i'll put'em out later.
 
Nah @ARr0w, get information from wherever you can! Only trust them if you can verify them though
 
8:55 AM
dude, are you available on facebook or any other place? diferent from work.
which is 'stack over flow'
yeah. I'll.
 
twitter basically I guess
Gave up on FB apart from birthday reminders a while back
 
9:08 AM
and i'm a facebooker.
skype, shaneis?
 
haha nope
had one for the last job but never set up a new one when I left it
 
i'm looking for a 'permanent' contact place, in case if you decide to disappear from here
create one for personal use?
 
A permanent contact place? Don't think there is a more permanent place than here and Twitter for me
Relax @ARr0w, I don't plan to be going anywhere for a while
 
if you decide too so, do leave something for me so that i can reach you.
 
will do
 
9:14 AM
thanks
 
9:43 AM
@ARr0w take it easy
we are mods here and we ain't gonna move away soon
 
Speaking of which, how's the rep coming @ARr0w?
 
10:06 AM
hey @SankarRaj
 
@AndyK Hi
 
10:50 AM
hi there
 
Hello @SunilChaudhry
 
hi @Shaneis
i want to delete duplicate records from a sql table
but not all records, except 1st entries
 
Sounds possible
 
WITH cte AS (
SELECT[foo], [bar],
row_number() OVER(PARTITION BY foo, bar ORDER BY baz) AS [rn]
FROM TABLE
)
DELETE cte WHERE [rn] > 1
i think dis should work
 
Tell you what, change that DELETE to a SELECT * FROM and whatever is returned is what is going to be deleted
also to format code here, highlight it and then press Ctrl + K
 
10:59 AM
ok
1 more thing , can we update a primary key column value without removing foreign key constraints?
 
you know one of the main things about Primary keys is they are supposed to not get updated, I think the term is immutable
if you need to update a PK, then I would say that you have a bad PK
 
hmm right.
 
but I don't know I've never tried
give me a minute and I'll test
 
okay, if my column has a value say "Shaneis" and if a front end user search it, and if the user misspells it and he/she search "shanis"
then is there any way to make the closest search
 
What platform are you using @SunilChaudhry
 
11:08 AM
c# .net @Shaneis
 
and what DB?
 
i want to know can we create any function , sp or any cte for the same?
sql
 
SQL Server? MySQL? Postgres?
 
sql server
 
Right, sounds like you are looking at Full-text search, or functions like SOUNDEX, or LIKE
Unfortunately I don't know much about them apart from that they exist
you probably need to research them or post a question on the main site
 
11:13 AM
ok @Shaneis thanks for the time, i will let you know if get something.
 
Good luck @SunilChaudhry
 
 
2 hours later…
1:02 PM
Say I have a view which contains two fields and contains the following records:
A 0
A 1
A 2
A 3
A 4
A 5
B 0
B 1
B 2
B 3
B 4
B 5
C 0
C 1
C 2
C 3
C 4
C 5
Is there an efficient way to get those records in the following order:
A 0
B 0
C 0
A 1
A 2
A 3
...
I'm using mysql 5
And I've tried doing something like
 
go ahead
 
select * from (
    (select * from t group by letter limit n)
    union distinct
    (select * from t limit n)
) tt
    limit n;
but it's terribly slow
obviously, the actual data I'm working with is more complex
perhaps most importantly, t is actually a view formed by a few joins
and I'm actually doing 2 unions
select plz, ort, strasse, strasse2, nr from (
	(select * from view_post_objekt group by ortid limit 20)
	union all
	(select * from view_post_objekt group by ortid, strid limit 20)
	union all
	(select * from view_post_objekt limit 20)
) t
	limit 20;
that's the real select
where view_post_objekt is:
SELECT new_plz1.onrp ortid, new_plz1.plz plz, new_plz1.ortbez27 ort, new_str.strid strid, new_str.strbez2l strasse, new_geba.geb_bez_alt strasse2, trim(concat(coalesce(new_geb.hnr, ''''), '' '', coalesce(new_geb.hnra, ''''))) nr FROM new_geb
    JOIN new_str ON
        new_str.strid = new_geb.strid
    JOIN new_plz1 ON
        new_plz1.onrp = new_str.onrp
    LEFT JOIN new_geba ON
        new_geba.hauskey = new_geb.hauskey;
onrp (ortid) is the primary key of new_plz1
strid is the primary key of new_str
 
should you use a select *?
how fast is the real select with the primary key?
 
I don't need the two ids in the final result, that shouldn't impact performance, right?
what do you mean by real select? the whole thing?
 
You tried this
 
1:17 PM
yes
 
SELECT new_plz1.onrp ortid, new_plz1.plz plz, new_plz1.ortbez27 ort, new_str.strid strid, new_str.strbez2l strasse, new_geba.geb_bez_alt strasse2, trim(concat(coalesce(new_geb.hnr, ''''), '' '', coalesce(new_geb.hnra, ''''))) nr FROM new_geb
    JOIN new_str ON
        new_str.strid = new_geb.strid
    JOIN new_plz1 ON
        new_plz1.onrp = new_str.onrp
    LEFT JOIN new_geba ON
        new_geba.hauskey = new_geb.hauskey;
how long it is?
 
without a limit?
let me check
 
it is the real thing, am I correct?
 
That's the query that defines view_post_objekt
that runs for 49 sec
 
that's (very) long
are there pk's (new_str.strid & new_geb.strid)?
 
1:20 PM
yup, those are the respective primary keys
 
and also these ones (new_plz1.onrp & new_str.onrp & new_geba.hauskey & new_geb.hauskey)
 
yeah
well, pk and fk respectively
onrp is pk on new_plz1 and fk on new_str
I should mention, new_geb has close to 2 million entries
 
so what I'm understanding is the main query, despite, having pk and fk, takes 49 seconds
2 millions rows make a table significant
 
select * from view_post_objekt limit 20 runs lightning fast
 
SELECT new_plz1.onrp ortid, new_plz1.plz plz, new_plz1.ortbez27 ort, new_str.strid strid, new_str.strbez2l strasse, new_geba.geb_bez_alt strasse2, trim(concat(coalesce(new_geb.hnr, ''''), '' '', coalesce(new_geb.hnra, ''''))) nr FROM new_geb
    JOIN new_str ON
        new_str.strid = new_geb.strid
    JOIN new_plz1 ON
        new_plz1.onrp = new_str.onrp
    LEFT JOIN new_geba ON
        new_geba.hauskey = new_geb.hauske limit 20
How long this one take?
 
1:25 PM
15 ms
hmm
select * from view_post_objekt group by ortid, strid limit 20;
takes close to 10 s
 
If you do

    SELECT * FROM (SELECT new_plz1.onrp ortid, new_plz1.plz plz, new_plz1.ortbez27 ort, new_str.strid strid, new_str.strbez2l strasse, new_geba.geb_bez_alt strasse2, trim(concat(coalesce(new_geb.hnr, ''''), '' '', coalesce(new_geb.hnra, ''''))) nr FROM new_geb
    JOIN new_str ON
        new_str.strid = new_geb.strid
    JOIN new_plz1 ON
        new_plz1.onrp = new_str.onrp
    LEFT JOIN new_geba ON
        new_geba.hauskey = new_geb.hauske limit 20) AS view_post_objekt group by ortid, strid
 
brb
I just tried
SELECT new_plz1.onrp ortid, new_plz1.plz plz, new_plz1.ortbez27 ort, new_str.strid strid, new_str.strbez2l strasse, new_geba.geb_bez_alt strasse2, trim(concat(coalesce(new_geb.hnr, ''''), '' '', coalesce(new_geb.hnra, ''''))) nr FROM new_geb
    JOIN new_str ON
        new_str.strid = new_geb.strid
    JOIN new_plz1 ON
        new_plz1.onrp = new_str.onrp
    LEFT JOIN new_geba ON
        new_geba.hauskey = new_geb.hauskey group by new_plz1.onrp, new_str.strid limit 20;
also roughly 10 s
 
the GROUP BY is making it more heavy
 
your version is very fast but is not giving me only 3 results
because it groups after limiting
it seems like it
 
can you create temp table ?
 
1:31 PM
but why? shouldn't the index make it easy?
@AndyK I've never used temp tables, what would that achieve?
 
temp table would act as very temporary array (kind of) that will last your session
if you are supposed to have only a dozen of records
it might be more a good way to store them
 
I'm not sure if that will help since I'll be adding a where clause with parameters to the final query
though I might be understanding you
 
and you have params
so the view sql will have params too ?
 
I mean params for a prepared statement
 
like @variable in the sql correct?
 
1:38 PM
no
sorry I might have expressed that poorly
I'll just add a where to:
select plz, ort, strasse, strasse2, nr from (
	(select * from view_post_objekt group by ortid limit 20)
	union all
	(select * from view_post_objekt group by ortid, strid limit 20)
	union all
	(select * from view_post_objekt limit 20)
) t
	limit 20;
And it won't always be the same
I might need to make view_post_objekt parameterized or just turn it into a function...
 
issue with the limit is that you will have the same 20 records each time
 
I know, I first used union distinct but tried out union all to see what difference it would make
select plz, ort, strasse, strasse2, nr from (
	(select * from view_post_objekt group by ortid limit 20)
	union distinct
	(select * from view_post_objekt group by strid limit 20)
	union distinct
	(select * from view_post_objekt limit 20)
) t
	limit 20;
is super fast
seems like the problem lies with group by ortid, strid
I might be able to leave away the group by two fields
I just figured that ortid is dependent on strid anyway, so I can just use the version I posted above
thanks for your help!
 
Why are you using GROUP BY?
to get the distinct values?
why not just use SELECT DISTINCT?
 
1:54 PM
the distinct will make a distinct on all the columns
 
While what? A group by will only make distinct the ortid?
 
 
2 hours later…
3:27 PM
bye everyone
see you tomorrow
 
bye
bro
 
See ya @AndyK
 
4:19 PM
the rep is on its place :p
@Shaneis just working on this product to finish to have time.
then i'll make some rep for myself.
 
g'man @ARr0w
Alright, I'm off man, talk again
 
alright, takecare bro
 

« first day (1566 days earlier)      last day (2752 days later) »