Showing posts with label group. Show all posts
Showing posts with label group. Show all posts

Thursday, March 29, 2012

Getting the most out of indexes (best practices and such)

Hi group,
This is a very general question about indexes and best practices, no DDL
will be provided.
There's a fairly indexed table with over 30mill records. Over 20 millions
have been added in the last 2 ws. I am noticing that queries that used to
run really fast take hours now. I can't even begin to contemplate how much
time it would take to rebuild indexes.
Also out of those 30millions probably 40% is duplicate records.
My question is will indexes be useful when there is such a ration of dups.
Should we concentrate on deduping this table then rebuilding indexes? Or
just rebuild indexes?
Also someone suggested creating another data file moving to another physical
drive and rebuild indexes storing it to the new file on separate physical
drive. That supposedly will make it much faster. Any truth to that?here is what I would do:
1. Make sure you have a clustered index on the table(s) in question. IF NOT,
bite the bullet and add one.
2. Check your fill factor settings so that inserts are not causing page
splits (Start at 70% and monitor page splits. If page splits remain high,
keep dropping that number. Probably dont want to go much lower than say 50%)
3. Use dbcc indexdefrag on a regular schedule (Nightly in my opinion) to
keep the table from becoming fragemented. This is an online operation so the
table(s) will be available during the defrag.
NOTE: teh first time you defrag these things, be prepared to watch the paint
dry. ALSO, logging activity will be really high. Make sure you have adequate
disk space for the logging and backup your logs very regularly OR put the
database in SIMPLE recovery mode while defragging (I'm not a fan of option
2)
I would not worry about de-duping unless the duplicate records are
unintentional and causing data integrity issues, etc.
the disk swapping thing is a waste of time in my opinion.
You are better off placing this massive table on it's own filegroup. Put
that File Group on a seperate RAID device with it's own controller if you
want. But I am not even convinced that this will be necessary (kind of a
fine tuning thing). Youve got bigger fish to fry with the basic index
maintenancne first.
Make sure that your database is on a RAID Disk (I guess I never asked if it
was). Your Data and indexes should be on RAID 1 or RAID 1+0 Volume
(Preferably RAID 1+0)
Your logs, and tempdb should be on RAID 1 or RAID 1+0 also (Again,
Preferabley RAID 1+0)
this will help for sure. But you might have more work to do to really get
this thing smoking.
Greg Jackson
PDX, Oregon|||You can update statistics, de-dupe your data, make sure you're using
clustered indexes, non-clustered indexes and Primary Keys appropriately (I
won't even ask how you ended up with 12 million duplicate records), defrag
your data and use QA to get your Estimated Query Execution Plans. For
starters.
Moving non-clustered indexes to their own physical drive will help improve
performance, as will moving the transaction log to its own physical drive.
"LP" <lp@.a.com> wrote in message
news:eSpK5LmLFHA.3296@.TK2MSFTNGP15.phx.gbl...
> Hi group,
> This is a very general question about indexes and best practices, no DDL
> will be provided.
> There's a fairly indexed table with over 30mill records. Over 20 millions
> have been added in the last 2 ws. I am noticing that queries that used
> to
> run really fast take hours now. I can't even begin to contemplate how much
> time it would take to rebuild indexes.
> Also out of those 30millions probably 40% is duplicate records.
> My question is will indexes be useful when there is such a ration of dups.
> Should we concentrate on deduping this table then rebuilding indexes? Or
> just rebuild indexes?
> Also someone suggested creating another data file moving to another
> physical
> drive and rebuild indexes storing it to the new file on separate physical
> drive. That supposedly will make it much faster. Any truth to that?
>|||Indexes are only of any use if the optimizer uses them, so its a good
idea to closely monitor which indexes are being used and which are not
and hence potentially redundant. Once that has been done then find out
the query plan for your scripts. This will show you which indexes your
script will use, if any.
Adrian
LP wrote:
> Hi group,
> This is a very general question about indexes and best practices, no DDL
> will be provided.
> There's a fairly indexed table with over 30mill records. Over 20 millions
> have been added in the last 2 ws. I am noticing that queries that used
to
> run really fast take hours now. I can't even begin to contemplate how much
> time it would take to rebuild indexes.
> Also out of those 30millions probably 40% is duplicate records.
> My question is will indexes be useful when there is such a ration of dups.
> Should we concentrate on deduping this table then rebuilding indexes? Or
> just rebuild indexes?
> Also someone suggested creating another data file moving to another physic
al
> drive and rebuild indexes storing it to the new file on separate physical
> drive. That supposedly will make it much faster. Any truth to that?
>

Tuesday, March 27, 2012

Getting the correct totals

I am trying to create a report and get a specific total, but it is not working correctly. I have a group of workers and I am able to count how many Work Orders they have worked on in a given month, however when I try to get a total of how many they completed, I run into a problem because it is counting every date that they worked as 1 instead of counting the # of work orders. Someone mentioned using a Global variable, but I am unsure how to use this.Try a running total, or if your count is in your details area, you should be able to right click it and insert a summary (group level if desired and report level)

Monday, March 26, 2012

getting sum group by page number

hi all,
i got a table, how can i get the sum of total ONLY for each page?(not sum of
the whole table)
thanks in advancegot the answer from the previous post...
please refer to thread "sum by page" if you guys have the same problem
"Jasonymk" wrote:
> hi all,
> i got a table, how can i get the sum of total ONLY for each page?(not sum of
> the whole table)
> thanks in advance

Getting sub totals in groups

Hi,
i have a table and a group in it..
i need to have subtotal column..
Im using the cost filed for grouping ...
i need to sum this filed and show it...
it seems that when i use the sum function alone,it sums all the cost values
ignoring the group
example
Project Reg ot Cost total cost
1 2 0 4 8
2 3 0 5 15
totals 5 o 13
isince there are 2 projects with cost 4 ,it sums incorrectly as 13,i
expect it to be 9...
any help please...
Thanks,Try adding a scope to your aggregate =Sum(Fields!Cost.Value, "Group_Name")
--
Douglas McDowell douglas@.nospam.solidqualitylearning.com
"CCP" <CCP@.discussions.microsoft.com> wrote in message
news:D582E6A9-B408-458C-AFC1-EFE709B0BD1D@.microsoft.com...
> Hi,
> i have a table and a group in it..
> i need to have subtotal column..
> Im using the cost filed for grouping ...
> i need to sum this filed and show it...
> it seems that when i use the sum function alone,it sums all the cost
> values
> ignoring the group
> example
> Project Reg ot Cost total cost
> 1 2 0 4 8
> 2 3 0 5 15
> totals 5 o 13
> isince there are 2 projects with cost 4 ,it sums incorrectly as
> 13,i
> expect it to be 9...
> any help please...
> Thanks,
>|||CCP,
If you've got you're group set properly (to project) you shouldn't need
to worry about scope. The sum should be in the group footer. In fact
you shouldn't have to specify 'Sum' at all, just dragging the Cost
field from the field list into a cell on the Group footer will sort the
syntax out for you.
What you are getting looks like you have it set in the TABLE footer,
not the GROUP footer.
Chris
Douglas McDowell wrote:
> Try adding a scope to your aggregate =Sum(Fields!Cost.Value,
> "Group_Name") --
> Douglas McDowell douglas@.nospam.solidqualitylearning.com
>
> "CCP" <CCP@.discussions.microsoft.com> wrote in message
> news:D582E6A9-B408-458C-AFC1-EFE709B0BD1D@.microsoft.com...
> > Hi,
> > i have a table and a group in it..
> > i need to have subtotal column..
> > Im using the cost filed for grouping ...
> > i need to sum this filed and show it...
> > it seems that when i use the sum function alone,it sums all the
> > cost values
> > ignoring the group
> > example
> > Project Reg ot Cost total cost
> > 1 2 0 4 8
> > 2 3 0 5 15
> >
> > totals 5 o 13
> >
> > isince there are 2 projects with cost 4 ,it sums incorrectly
> > as 13,i
> > expect it to be 9...
> >
> > any help please...
> >
> > Thanks,
> >

Wednesday, March 21, 2012

Getting rid of the time value from a datetime field

I want to get rid of the time stamp in a datetime field and also i need to include that in a group by query.

For Ex:

select join_dt, avg(salary) from employee
group by join_dt

Here in the above example, join_dt is a datetime field, i need some function similar datepart which gives only the date part of the join_dt.you can use the function DATEPART. See Books Online for more information.|||I think you just answered you own question...

why don't u use datepart?

you could do something like this:

select join_dt, avg(salary) from employee
group by datepart("datepartchoice",join_dt)

or are u trying to say something else?|||@.Patrick: hopefully you are not insulted by this remark, but didn't I post just the same answer as you did?|||No offence taken, I was just wondering what was getbabs really asking, since his question was already containing the answer :

getbabs>>i need some function similar datepart which gives only the date part of the join_dt.

:)|||I am looking for a formatted date ("dd/mm/yy") from a datetime field
and group by the same.|||select convert(varchar(12), getDate(), 6) where the 6 stands for the format used. Look under CONVERT in Books Online for the formats.|||i think the real problem here is why does join_dt have a time component

i could see the need for a time component in other datetime fields, but not this one

if you need to use DATEPART in order to use GROUP BY on the date portion only, this a sure sign that you have been manouevered into a very bad situation by poor design or coding

using DATEPART usually rules out indexes, and the query will perform poorly

do yourself a favour, and reset the time portion of all the join_dt to midnight

then you can go ahead and write simple queries like this --

select join_dt, avg(salary) from employee
group by join_dt

;)|||As an extension to Rudy's post, you could consider an additional time column if time is really required. Update the time column with the time component from the join_dt field and then blank the join_dt field to midnight. Having said that, I agree with him inasmuch as what's a time doing in a join date?

Monday, March 12, 2012

Getting Problem in giving database permission to group user

hi ,

I am getting some problem in using group in sql server login.

i have two NT groups in windows.i) developer and tester

I added a user Lalit in both gruop. I want to give db_owner permission on a particular database(Employee) to developer group and data_denyreader and deny_writer on same database(Employee) to tester group.

Now when i logging in to sql server using Lalit(windows authentication) iam not able to access the database(Employee).

Now my concern is that Lalit should have full access to the employee database when entered as developer user and limited access to employee database when entered as tester user.

how can i achieve this set up?

Please do help.

Thanks a lot in advance !!!!!!!!!!!!!!!!!!

Deny trumps any other permission (other than SA). For my testing groups, I set up SQL Server login accounts, one called "Owner" and the other called "tester". That way when the devs log in they don't have to change NT contexts.