Subject | Garbage collection - will this work? |
---|---|
Author | Peter Ypenburg |
Post date | 2005-06-21T14:26:36Z |
Hi All,
We have a transactional table that looks like this:
CREATE TABLE ITEMDAILYFORECAST (
ITEMDAILYFORECASTNO INTEGER NOT NULL, /*just a unique integer*/
ITEMNO INTEGER NOT NULL, /*a unique item*/
FORECASTTYPENO INTEGER NOT NULL, /*a value for the type of FC e.g. 3*/
FORECASTDATE DATE NOT NULL, /*a date for the FC value*/
FCVALUE DOUBLE PRECISION DEFAULT 0, /*the FC value*/
LOCATIONNO INTEGER NOT NULL, /*the location the item belongs to*/
CONSTRAINT PK_ITEMDAILYFORECAST PRIMARY KEY (ITEMDAILYFORECASTNO)
);
We have the following foreign keys:
ALTER TABLE ITEMDAILYFORECAST ADD CONSTRAINT FK_ITEMDAILYFC_FCTYPE FOREIGN
KEY (FORECASTTYPENO) REFERENCES FORECASTTYPE(FORECASTTYPENO);
ALTER TABLE ITEMDAILYFORECAST ADD CONSTRAINT FK_ITEMDAILYFC_ITEM FOREIGN KEY
(ITEMNO) REFERENCES ITEM(ITEMNO);
And a index on the location and type of FC
CREATE INDEX IDX_LOCATION_FCTYPE ON
ITEMDAILYFORECAST(LOCATIONNO,FORECASTTYPENO);
We have a batch process that runs every night and then we delete all the
rows for a given location and a FC type e.g.
delete from ITEMDAILYFORECAST
Where LOCATIONNO = 1
and FORECASTTYPENO = 4
We then want to take care of garbage and conventionally we would have done
something like this:
select count(*)
from ITEMDAILYFORECAST
My question is, if I run a query
select count(*)
from ITEMDAILYFORECAST
Where LOCATIONNO = 1
and FORECASTTYPENO = 4
Will this achieve the same result for garbage collection given the index I
have on the table?
Peter Ypenburg
We have a transactional table that looks like this:
CREATE TABLE ITEMDAILYFORECAST (
ITEMDAILYFORECASTNO INTEGER NOT NULL, /*just a unique integer*/
ITEMNO INTEGER NOT NULL, /*a unique item*/
FORECASTTYPENO INTEGER NOT NULL, /*a value for the type of FC e.g. 3*/
FORECASTDATE DATE NOT NULL, /*a date for the FC value*/
FCVALUE DOUBLE PRECISION DEFAULT 0, /*the FC value*/
LOCATIONNO INTEGER NOT NULL, /*the location the item belongs to*/
CONSTRAINT PK_ITEMDAILYFORECAST PRIMARY KEY (ITEMDAILYFORECASTNO)
);
We have the following foreign keys:
ALTER TABLE ITEMDAILYFORECAST ADD CONSTRAINT FK_ITEMDAILYFC_FCTYPE FOREIGN
KEY (FORECASTTYPENO) REFERENCES FORECASTTYPE(FORECASTTYPENO);
ALTER TABLE ITEMDAILYFORECAST ADD CONSTRAINT FK_ITEMDAILYFC_ITEM FOREIGN KEY
(ITEMNO) REFERENCES ITEM(ITEMNO);
And a index on the location and type of FC
CREATE INDEX IDX_LOCATION_FCTYPE ON
ITEMDAILYFORECAST(LOCATIONNO,FORECASTTYPENO);
We have a batch process that runs every night and then we delete all the
rows for a given location and a FC type e.g.
delete from ITEMDAILYFORECAST
Where LOCATIONNO = 1
and FORECASTTYPENO = 4
We then want to take care of garbage and conventionally we would have done
something like this:
select count(*)
from ITEMDAILYFORECAST
My question is, if I run a query
select count(*)
from ITEMDAILYFORECAST
Where LOCATIONNO = 1
and FORECASTTYPENO = 4
Will this achieve the same result for garbage collection given the index I
have on the table?
Peter Ypenburg