  We study the model-checking problem for first- and monadic second-order logic
on finite relational structures. The problem of verifying whether a formula of
these logics is true on a given structure is considered intractable in general,
but it does become tractable on interesting classes of structures, such as on
classes whose Gaifman graphs have bounded treewidth. In this paper we continue
this line of research and study model-checking for first- and monadic
second-order logic in the presence of an ordering on the input structure. We do
so in two settings: the general ordered case, where the input structures are
equipped with a fixed order or successor relation, and the order invariant
case, where the formulas may resort to an ordering, but their truth must be
independent of the particular choice of order. In the first setting we show
very strong intractability results for most interesting classes of structures.
In contrast, in the order invariant case we obtain tractability results for
order-invariant monadic second-order formulas on the same classes of graphs as
in the unordered case. For first-order logic, we obtain tractability of
successor-invariant formulas on classes whose Gaifman graphs have bounded
expansion. Furthermore, we show that model-checking for order-invariant
first-order formulas is tractable on coloured posets of bounded width.
