postgresql-operation-counting
Safe HaskellSafe-Inferred
LanguageHaskell2010

PostgreSQL.Count

Synopsis

Counting SQL operations

data SQLOperationCounts Source #

This tracks the number of SQL operations that have been performed, along with which table they were performed on (where possible).

INSERT, DELETE and UPDATE operations act on one table only, so we can tally the number of each that are performed on each table (indexed by a TableName). SELECT operations can act on multiple tables, so we just track the total number of selects.

If required, SQLOperationCounts can be constructed using Monoid, added using Semigroup, and subtracted using subtractCounts.

We use non-negative Naturals as a tally since a negative number of operations makes no sense.

Instances

Instances details
Monoid SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

Semigroup SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

Generic SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

Associated Types

type Rep SQLOperationCounts :: Type -> Type #

Show SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

Eq SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

Pretty SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

type Rep SQLOperationCounts Source # 
Instance details

Defined in PostgreSQL.Count

type Rep SQLOperationCounts = D1 ('MetaData "SQLOperationCounts" "PostgreSQL.Count" "postgresql-operation-counting-0.1.0.1-inplace" 'False) (C1 ('MetaCons "SQLOperationCounts" 'PrefixI 'True) ((S1 ('MetaSel ('Just "sqlSelects") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural) :*: S1 ('MetaSel ('Just "sqlInserts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TableName Natural))) :*: (S1 ('MetaSel ('Just "sqlDeletes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TableName Natural)) :*: S1 ('MetaSel ('Just "sqlUpdates") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TableName Natural)))))

data TableName Source #

The name of a table, optionally qualified with a schema.

Constructors

TableName 

Instances

Instances details
Generic TableName Source # 
Instance details

Defined in PostgreSQL.Count

Associated Types

type Rep TableName :: Type -> Type #

Show TableName Source # 
Instance details

Defined in PostgreSQL.Count

Eq TableName Source # 
Instance details

Defined in PostgreSQL.Count

Ord TableName Source # 
Instance details

Defined in PostgreSQL.Count

Pretty TableName Source # 
Instance details

Defined in PostgreSQL.Count

type Rep TableName Source # 
Instance details

Defined in PostgreSQL.Count

type Rep TableName = D1 ('MetaData "TableName" "PostgreSQL.Count" "postgresql-operation-counting-0.1.0.1-inplace" 'False) (C1 ('MetaCons "TableName" 'PrefixI 'True) (S1 ('MetaSel ('Just "tableSchema") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "tableName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

subtractCounts :: SQLOperationCounts -> SQLOperationCounts -> SQLOperationCounts Source #

Subtract one set of counts from another. Note that the results are all still Naturals, so will all be non-negative.

Pretty-printing

printCounts :: MonadIO m => SQLOperationCounts -> m () Source #

Print an SQLOperationCounts to stdout using prettyCounts. For less verbose output, see printCountsBrief.

printCountsBrief :: MonadIO m => SQLOperationCounts -> m () Source #

Print an SQLOperationCounts to stdout using prettyCountsBrief. For more verbose output, see printCounts.

renderCounts :: SQLOperationCounts -> String Source #

Render an SQLOperationCounts using prettyCounts. For less verbose output, see renderCountsBrief.

For more control over how the Doc gets rendered, use renderStyle with a custom style.

renderCountsBrief :: SQLOperationCounts -> String Source #

Render an SQLOperationCounts using prettyCountsBrief. For more verbose output, see renderCounts.

For more control over how the Doc gets rendered, use renderStyle with a custom style.

prettyCounts :: SQLOperationCounts -> Doc Source #

Pretty-print an SQLOperationCounts using Text.PrettyPrint. For each Map, we'll print one line for each table. For less verbose output, see prettyCountsBrief.

This is also the implementation of pPrint for SQLOperationCounts.

prettyCountsBrief :: SQLOperationCounts -> Doc Source #

Pretty-print an SQLOperationCounts using Text.PrettyPrint. For each Map, we'll print just the sum of the counts. For more verbose output, see prettyCounts.